Skip to main content
Spawning uses eventlet to do non-blocking IO for http requests and responses. This means the server will scale to a large number of keep-alive connections easily. However, it also delegates requests using other forms of multiprocessing and is configurable to be useful in a wide variety of situations. It supports multiple Python processes as well as a threadpool.

Single or Multiple Process
==========================

If your wsgi applications store state in memory, Spawning can be configured to run only one Python process. In this configuration your application state will be available to all requests but your application will not be able to take full advantage of multiple processors. Using multiple processes will take advantage of all processors and thus should be used for applications which do not share state.

Single or Multiple Worker Thread (or Worker Process)
=========================

If your wsgi applications perform a certain subset of blocking calls which have been monkeypatched by eventlet to cooperate instead (such as operations in the socket module), you can configure each process to run only a single main thread and cooperate using greenlet microthreads instead. This can be useful if your application is very small and needs to scale to a large number of simultaneous requests, such as a COMET server or an application which uses AJAX polling. However, most existing wsgi applications will probably perform blocking operations (for example, calling database adapter libraries which perform blocking socket operations). Therefore, for most wsgi applications a combination of multiple processes and multiple threads will be ideal.

Graceful Code Reloading
=======================
By default, Spawning watches all Python files that are imported into sys.modules for changes and performs a graceful reload on change. Old processes are told to stop accepting requests and finish any outstanding requests they are servicing, and shutdown. Meanwhile, new processes are started and begin accepting requests and servicing them with the new code. At no point will users of your site see "connection refused" errors because the server is continuously listening during reload.

Running spawning
================

Spawning can be used to launch a wsgi application from the command line using the "spawn" script, or using Python Paste. To use with paste, specify use = egg:Spawning in the [server:main] section of a paste ini file.

Spawning can also be used to run a Django application by using --factory=spawning.django_factory.config_factory.

Examples of running spawning:

% spawn my_wsgi_module.my_wsgi_application

This will run the wsgi application callable called "my_wsgi_application" inside the my_wsgi_module.py file.

% spawn --factory=spawning.paste_factory.config_factory development.ini

Run whatever is configured inside of development.ini. Equivalent to using paster serve with an ini file configured to use Spawning as the server.

% spawn --factory=spawning.django_factory.config_factory mysite.settings

Run the Django app mysite.

% spawn my_wsgi_module.my_wsgi_application other_wsgi_module.some_wsgi_middleware

Run the wsgi application wrapped with some middleware. Pass as many middleware strings as desired after the wsgi application name.

% sudo spawn --port=80 --processes=4 --threads=8 my_wsgi_module.my_wsgi_application

Run the wsgi application on port 80, with 4 processes each using a threadpool of size 8.

% spawn --processes=4 --threads=0 my_wsgi_module.my_comet_application

Use a threadpool of size 0, which indicates that eventlet monkeypatching should be performed and wsgi applications should all be called in the same thread. Useful for writing a comet-style application where a lot of requests are simply waiting on a server-side event or internal network io to complete.

Metadata

Release files for Spawning 0.8.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for Spawning 0.8.1
File Size Uploaded
Spawning-0.8.1.tar.gz 13.9 kB Details

Release files / Spawning-0.8.1.tar.gz

Download URL Spawning-0.8.1.tar.gz
Size 13.9 kB
Tags Source
SHA-256 checksum
How to use checksums
8e996fce1ba4a51ea6dc2b0be7cea1ad3a48f2e05fc0d301c6f6467a71b916ee
BLAKE2b-256 checksum
How to use checksums
15c93c43aa24c31dba30324f4aafdf299d76954b3473ee7b202d253544f584b9
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No

Release history Release notifications | RSS feed

0.9.7

1 release file

0.9.6

1 release file

0.9.5

1 release file

0.9.4

1 release file

0.9.2

1 release file

0.9.1

1 release file

0.9

1 release file

0.8.12

1 release file

0.8.11

1 release file

0.8.10

1 release file

0.8.9

1 release file

0.8.8

1 release file

0.8.7

1 release file

0.8.6

1 release file

0.8.5

1 release file

0.8.4

1 release file

0.8.3

1 release file

0.8.2

1 release file

This release

0.8.1 This release

1 release file

0.8

1 release file

0.7

1 release file

0.6

1 release file

0.5.1

1 release file

0.5

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page