SHARE
TWEET

Untitled

siddharth-gangadhar Jun 3rd, 2020 1,123 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. def insert_data(self, processed_data):
  2.     db_session_commit(processed_data)
  3.  
  4. def calculate_something(self, data):
  5.     processed_data = external_lib_function(data)
  6.     print(processed_data)
  7.  
  8. async def wrapper(self, data):
  9.     processed_data = self.calculate_something(data)
  10.     self.insert_data(processed_data)
  11.  
  12. async def main():
  13.     if True:
  14.         global nursery
  15.         async with trio.open_nursery() as _nursery:
  16.             nursery = _nursery
  17.             await trio.to_thread.run_sync(self.wrapper, data)
  18.  
  19. trio.run(main)
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
Top