How to use the pebble.thread.concurrent function in Pebble

To help you get started, we’ve selected a few Pebble examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github noxdafox / pebble / tests / test_thread_concurrent.py View on Github external
def test_undecorated_callback(self):
        """Thread Concurrent undecorated results are forwarded to callback."""
        task = thread.concurrent(target=undecorated, args=[1],
                                 kwargs={'keyword_argument': 1},
                                 callback=self.callback)
        event.wait()
        self.assertEqual(task.get(), 2)
github noxdafox / pebble / tests / test_thread_concurrent.py View on Github external
    @thread.concurrent
    def instmethod(self):
        return self.b
github noxdafox / pebble / tests / test_thread_concurrent.py View on Github external
@thread.concurrent
def error_decorated():
    raise Exception("BOOM!")
github noxdafox / pebble / tests / test_thread_concurrent.py View on Github external
@thread.concurrent(callback=callback)
def long_decorated_callback():
    time.sleep(1)
github noxdafox / pebble / tests / test_thread_concurrent.py View on Github external
@thread.concurrent(callback=callback)
def decorated_callback(argument, keyword_argument=0):
    """A docstring."""
    return argument + keyword_argument
github noxdafox / pebble / tests / test_thread_concurrent.py View on Github external
            @thread.concurrent(5, name='foo')
            def wrong():
                return
        except Exception as error:
github noxdafox / pebble / tests / test_thread_concurrent.py View on Github external
def test_undecorated_results(self):
        """Process Concurrent undecorated results are produced."""
        task = thread.concurrent(target=undecorated_simple)
        self.assertEqual(task.get(), 0)
github noxdafox / pebble / pebble / process / task.py View on Github external
@thread_worker(daemon=True)
def task_manager(task):
    """Task's lifecycle manager.

    Starts a new worker, waits for the *Task* to be performed,
    collects results, runs the callback and cleans up the process.

    """
    queue = task._queue
    function = task._function
    timeout = task.timeout > 0 and task.timeout or None

    process = task_worker(queue, function, task._args, task._kwargs)

    try:
        results = queue.get(timeout)
        task._set(results)