Django: Run the development server in multi-threaded mode

If you were to have content in your template which displayed content from an RSS feed hosted by your dev server, it would time out.

The reason why this happens is because the standard Django dev server does not support concurrency natively.

That means the first request to your template page would stay open while the tag opens a secondary connection to your RSS feed.

Because the dev server is single-threaded, it would keep waiting until the first request is finished before allowing the RSS thread to be parsed.

Eventually it times out and gives up, giving you an error.

Luckily, to get around this you don't have to modify the core Django files.

A user at github named James Aylett (jaylett) has created an excellent Django command called runconcurrentserver which allows you to start the server using an alternate command instead of "runserver" while still supporting the same arguments.

To use it:

  • Simply grab the files off his git repository or download using the browser.
  • Extract (if you downloaded the archive)
  • Move the files from "concurrent_test_server" and save it in "your_project/django_concurrent_server".
  • Add it to your INSTALLED_APPS settings
  • Now you can run it using:

python manage.py runconcurrentserver

Easy as pi.

tumblr_lcmt12RuJb1qai0xlo1_250 
Now you can continue being awesome.

Sources

 
Copyright © Twig's Tech Tips
Theme by BloggerThemes & TopWPThemes Sponsored by iBlogtoBlog