python - How to mix asyncio code in with blocking code? -


this question has answer here:

how go mixing code/statements/functions want run outside main thread mixed in code strickly runs on main thread.

in mobile world have tools rxjava, asynctask, runnables, rxswift , stuff drop in lines run in background , not bother fluidness of main code.

so how utilize asyncio lib , intermingle non blocking code blocking code?

   def mumbojumbocode():         regularstuff = dosomeregularstuff()         illgetitlater = sendsomestufftoawebsocketinthebackground(regularstuff)         moreregularstuff = dosomemoreregularstuff()         idontcarewhatitreturns = sendamessageoverthewire(illgetitlater)         if (moreregularstuff => regularstuff):               triggeralambdasomewhereinthecloud(moreregularstuff) 

you can simulate blocking code while in async mode, not other way around.

so, if program system in async mode, can set flag in event handler, , wait flag change in polling loop, changing mode sync mode. if want asynchronously, can change behavior of handler.


Comments

Popular posts from this blog

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

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

StringGrid issue in Delphi XE8 firemonkey mobile app -