Advertisement
siddharth-gangadhar

Untitled

Jun 3rd, 2020
1,687
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.53 KB | None | 0 0
  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)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement