This is a pre-production deployment of Warehouse, however changes made here WILL affect the production instance of PyPI.
Latest Version Dependencies status unknown Test status unknown Test coverage unknown
Project Description

A Python library for using callbacks to resume your code.

resumeback provides a utility function decorator that enables using callback-based interfaces in a single line of execution – a single function.

Full docs are available here:


$ pip install resumeback


resumeback.send_self’s mechanic of sending a generator function a handle to itself is what allows for better flow control using callback-based interfaces. Essentially, it enables a single line of execution.

Following is a function that uses an asynchronous callback mechanism to signal that user input has been made:

from threading import Thread

def ask_for_user_input(question, on_done):
    def watcher():
        result = input(question)


The traditional way of using a function like ask_for_user_input would be to define a function of some way, either as a closure or using functools.partial so that we can preserve the state we already accumulated prior to executing said function.

For example like so:

def main():
    arbitrary_value = 10

    def on_done(number):
        number = str(number)
        print("Result:", number * arbitrary_value)

    ask_for_user_input("Please enter a number", on_done)

Because Python does not have multi-line inline functions, this is rather awkward, because we are jumping from the function call of ask_for_user_input back to our previously defined function on_done – which is only ever going to be called once in this context.

However, using resumeback.send_self, we can do something to flatten our line of execution by passing a callback to resume execution in our original function:

from resumeback import send_self

def main():
    this = yield  # "this" is now a reference to the just-created generator
    arbitrary_value = 10

    # Yield pauses execution until one of the generator methods is called,
    # such as `.send`, which we provide as the callback parameter.
    number = yield ask_for_user_input("Please enter a number", this.send)
    number = str(number)
    print("Result:", number * arbitrary_value)


Project started initially after a forum post from @Varriount on the Sublime Text forum. I just took his idea “to the next (abstraction) level” and made it more convenient to use.

Release History

Release History


This version

History Node

TODO: Figure out how to actually get changelog content.

Changelog content for this version goes here.

Donec et mollis dolor. Praesent et diam eget libero egestas mattis sit amet vitae augue. Nam tincidunt congue enim, ut porta lorem lacinia consectetur. Donec ut libero sed arcu vehicula ultricies a non tortor. Lorem ipsum dolor sit amet, consectetur adipiscing elit.

Show More

Download Files

Download Files

TODO: Brief introduction on what you do with files - including link to relevant help section.

File Name & Checksum SHA256 Checksum Help Version File Type Upload Date
resumeback-0.1.0-py2.py3-none-any.whl (8.5 kB) Copy SHA256 Checksum SHA256 py2.py3 Wheel Dec 10, 2015 (11.5 kB) Copy SHA256 Checksum SHA256 Source Dec 10, 2015

Supported By

WebFaction WebFaction Technical Writing Elastic Elastic Search Pingdom Pingdom Monitoring Dyn Dyn DNS Sentry Sentry Error Logging CloudAMQP CloudAMQP RabbitMQ Heroku Heroku PaaS Kabu Creative Kabu Creative UX & Design Fastly Fastly CDN DigiCert DigiCert EV Certificate Rackspace Rackspace Cloud Servers DreamHost DreamHost Log Hosting