Commit 50779cac authored by Lucia Rinchiuso's avatar Lucia Rinchiuso
Browse files

Waiting process

parent 202c03ce
......@@ -2,6 +2,7 @@ import sys
import os
import inspect
import importlib
from multiprocessing import Pool
def localdir(follow_symlinks=True):
if getattr(sys, 'frozen', False): # py2exe, PyInstaller, cx_Freeze
......@@ -34,3 +35,24 @@ def compilef90(mod, mpi=None) :
mpimod.COMM_WORLD.Barrier()
return
def waitingAnimation(n):
import time
n = n%3+1
dots = n*'.'+(3-n)*' '
sys.stdout.write('\r Waiting '+ dots)
sys.stdout.flush()
time.sleep(0.5)
return n
def waitingProcess(f,x):
with Pool(processes=1) as pool:
res = pool.apply_async(f, (x,))
waiting, n = True, 0
while waiting:
try:
waiting = not res.successful()
R = res.get()
except AssertionError:
n = waitingAnimation(n)
sys.stdout.write('\r Loading complete\n')
return R
......@@ -53,12 +53,33 @@ import Locations as LO
#
# Read all the gauging stations positoned in the routing graph
#
L = LO.PlacedLocations(GraphFile)
def fL(GraphFile):
L = LO.PlacedLocations(GraphFile)
return L
print('\n Starting loading locations')
L=F90T.waitingProcess(fL,GraphFile)
#print('\n Starting loading locations')
#with Pool(processes=1) as pool:
# res = pool.apply_async(fL, (GraphFile,))
# waiting, n = True, 0
# while waiting:
# try:
# waiting = not res.successful()
# L = res.get()
# except AssertionError:
# n = F90T.waitingAnimation(n)
# sys.stdout.write('\r Loading complete\n')
#
# Read all the stations in the river gauge (GRDC) data base
#
A=AS.AllStations()
A.fetchnetcdf(GRDCFile, metaonly=True, region=[L.lonrange,L.latrange])
def fA(GRDCFile):
A=AS.AllStations()
A.fetchnetcdf(GRDCFile, metaonly=True, region=[L.lonrange,L.latrange])
return A
print('\n Starting loading GRDC file')
A=F90T.waitingProcess(fA,GRDCFile)
#
# Find the IDs of all the stations and exclusions listed in stations.def
#
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment