prompy.threadio package

prompy.threadio.pooled_caller module

class prompy.threadio.pooled_caller.PooledCaller(**pool_kwargs)[source]

Bases: prompy.container.BasePromiseContainer

Class wrapper for urlcall. Auto-add calls to a PromiseQueuePool to be resolved.

__init__(**pool_kwargs)[source]

Initialize self. See help(type(self)) for accurate signature.

add_promise(promise)[source]

Add a promise to the container.

Parameters:promise (Promise[~PromiseReturnType]) –
Returns:
call(url, **kwargs)[source]
Return type:Promise[]
get(url, **kwargs)[source]
head(url, **kwargs)[source]
json_call(url, **kwargs)[source]
post(url, **kwargs)[source]
put(url, **kwargs)[source]

prompy.threadio.promise_queue module

class prompy.threadio.promise_queue.PromiseQueue(start=False, max_idle=0.5, on_stop=None, queue_timeout=0.01, interval=0.01, daemon=False)[source]

Bases: prompy.container.PromiseContainer

__init__(start=False, max_idle=0.5, on_stop=None, queue_timeout=0.01, interval=0.01, daemon=False)[source]

Initialize self. See help(type(self)) for accurate signature.

add_promise(promise)[source]

Add a promise to the container.

Parameters:promise (Promise[~PromiseReturnType]) –
Returns:
cancel(cancel_id)[source]
error
running
start()[source]
stop()[source]
class prompy.threadio.promise_queue.PromiseQueuePool(pool_size=8, start=False, max_idle=0.5, daemon=False)[source]

Bases: prompy.container.BasePromiseRunner

__init__(pool_size=8, start=False, max_idle=0.5, daemon=False)[source]

Initialize self. See help(type(self)) for accurate signature.

add_promise(promise)[source]

Add a promise to the container.

Parameters:promise (Promise[~PromiseReturnType]) –
Returns:
is_running()[source]
on_thread_stop(func)[source]
start()[source]
stop()[source]

prompy.threadio.tpromise module

Threaded Promise

Auto insert in a global thread pool.

Use the following environ vars:

  • PROMPY_THREAD_POOL_SIZE=2
  • PROMPY_THREAD_IDLE_TIME=0.5
  • PROMPY_THREAD_DAEMON=false
class prompy.threadio.tpromise.TPromise(starter, *args, **kwargs)[source]

Bases: prompy.promise.Promise

A promise with auto insert in a threadio.PromiseQueue.

__init__(starter, *args, **kwargs)[source]

Promise takes at least a starter method with params to this promise resolve and reject. Does not call exec by default but with start_now the execution will be synchronous.

Parameters:
  • starter – otherwise known as executor.
  • then – initial resolve callback
  • catch – initial catch callback
  • complete – initial complete callback
  • raise_again – raise the rejection error again.
  • start_now
  • results_buffer_size – number of results to keep in the buffer.
classmethod stop_queue()[source]
classmethod wrap(func)[source]