6. Emulation

Because Shrapnel is essentially its own threading system, code written with the intention of using Python’s standard threads will not work. Things like Python’s socket class will block and hang the entire program. To solve this problem, Shrapnel includes some code that will monkeypatch some of Python’s standard classes to work with Shrapnel. You must manually enable this behavior by calling coro.install_thread_emulation().

coro.install_thread_emulation()

Install Python threading emulation.

It is recommended that you call this at the very beginning of the main script of your application before importing anything else. This will cause the following modules to be emulated:

  • thread
  • threading
  • socket

At this time, no other blocking operations are supported.

This Page