コード例 #1
0
def time_loop():
    """timer function whose purpose is to call itself every N seconds 
		without stopping. Calls some other function after setting 
		itself to go off again"""
    threading.Timer(10, time_loop).start()  # int is delay in seconds
    # request new vehicles and store them
    get_new_vehicles()
コード例 #2
0
ファイル: store.py プロジェクト: SAUSy-Lab/nb-gtfs
def time_loop():
	"""timer function whose purpose is to call itself every N seconds 
		without stopping. Calls some other function after setting 
		itself to go off again"""
	threading.Timer( 10, time_loop ).start() # int is delay in seconds
	# request new vehicles and store them
	get_new_vehicles()
コード例 #3
0
		itself to go off again"""
    threading.Timer(10, time_loop).start()  # int is delay in seconds
    # request new vehicles and store them
    get_new_vehicles()


if truncateData:
    db.empty_tables()

if getRoutes:
    # get all the route data, afresh
    # threading this makes it faster
    #print 'requesting all route data'
    routes = all_routes()
    for route_id in routes:
        t = threading.Thread(target=fetch_route, args=(route_id, ))
        t.start()
        if threading.active_count() >= 20:
            sleep(3)

    sleep(10)

# call the big function. This takes longer to run the first time,
get_new_vehicles()

# so wait a bit longer than usual to call the timer function 10secs later
while True:
    sleep(10)
    get_new_vehicles()

# then it calls itself every N secs
コード例 #4
0
ファイル: store.py プロジェクト: SAUSy-Lab/nb-gtfs
def time_loop():
	"""timer function whose purpose is to call itself every N seconds 
		without stopping. Calls some other function after setting 
		itself to go off again"""
	threading.Timer( 10, time_loop ).start() # int is delay in seconds
	# request new vehicles and store them
	get_new_vehicles()

if truncateData:
	db.empty_tables()

if getRoutes:
	# get all the route data, afresh
	# threading this makes it faster
	#print 'requesting all route data'
	routes = all_routes()
	for route_id in routes:
		t = threading.Thread(target=fetch_route,args=(route_id,))
		t.start()
		if threading.active_count() >= 10:
			sleep(3)

	sleep(10)

# call the big function. This takes longer to run the first time, 
get_new_vehicles()

# so wait a bit longer than usual to call the timer function 10secs later
threading.Timer( 10, time_loop ).start()
# then it calls itself every N secs