Advertisement
Guest User

Untitled

a guest
Apr 12th, 2018
97
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.61 KB | None | 0 0
  1. async def process_function(argument, row, file_stats, db_session):
  2.     switcher = {
  3.         0: process_log_in,
  4.         1: process_launch_application,
  5.         2: process_enter_application,
  6.         3: process_exit_application,
  7.         4: process_access_screen,
  8.         5: process_log_out,
  9.         6: process_time_out
  10.     }
  11.     # Get the function from switcher dictionary
  12.     func = switcher.get(argument, lambda: "nothing")
  13.     # Execute the function
  14.     ret = func(row, file_stats, db_session)
  15.     if asyncio.iscoroutine(ret):
  16.         # func returned a coroutine, await it
  17.         ret = await ret
  18.     return ret
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement