python - How to properly run two while loops in asyncio code with executor pools? -


i have 2 functions want run concurrently. heartbeat function, executes simple while loop. , function meat of script, that's in while loop.

while heartbeat functions marches along, meat , potatoes function ruins once , never loops...

i'm using asyncio , executor pools accomplish goals of having 2 functions (loops) running simulutaneously.

also how errors/exception show while using executor pools, cant see errors....

here's code:

   import lib.myfunctions    import asyncio    import oandapy            fmc = lib.myfunctions.fmcmixin()     def meatandpotatoes(currency_pair=sys.argv[1],         time_compression=sys.argv[2],sleep_time=sys.argv[3]):         while true:            try:              = oanda.get_history()              if (something):                   print("niceeee")              else:                   print("ok cool")            except:              sleep(sleep_time)      if __name__ == "__main__":       executor = processpoolexecutor(2)       loop = asyncio.get_event_loop()       asyncio.async(loop.run_in_executor(executor, meatandpotatoes))       scriptname = str(sys.argv[1]+"/"+sys.argv[2]+"/")       asyncio.async(loop.run_in_executor(executor, \          fmc.heartbeatfunction(scriptname)))       loop.run_forever() 


Comments

Popular posts from this blog

android - Gradle sync Error:Configuration with name 'default' not found -

java - Andrioid studio start fail: Fatal error initializing 'null' -

html - jQuery UI Sortable - Remove placeholder after item is dropped -