result () # blocks until results are ready except TimeoutError as error : print ( "Function took longer than %d seconds" % error. process ( timeout = 10 ) def function ( foo, bar = 0 ): return foo + bar future = function ( 1, bar = 2 ) try : result = future. from pebble import concurrent from concurrent.futures import TimeoutError. Run a function with a timeout of ten seconds and deal with errors. thread def function ( foo, bar = 0 ): return foo + bar async def asynchronous_function (): result = await function ( 1, bar = 2 ) # blocks until results are ready print ( result ) asyncio. import asyncio from pebble import asynchronous. result () # blocks until results are ready thread def function ( foo, bar = 0 ): return foo + bar future = function ( 1, bar = 2 ) result = future. Run a job in a separate thread and wait for its results. Pebble provides a neat API to manage threads and processes within an application.
0 Comments
Leave a Reply. |