Skip to main content

Patch Python function objects with a gevent-backed go() helper.

Project description

goesque

Tests

goesque patches Python function objects with a go() method backed by gevent.spawn, so regular functions can be launched in a Go-like style.

Quick example

import goesque

goesque.patch_all()

def side_effect():
    print("Side effect!")

side_effect.go()
# out: Side effect!

How it works

goesque.patch_all() does two things:

  1. Calls gevent.monkey.patch_all() so standard library I/O becomes cooperative.
  2. Patches types.FunctionType so every Python function gains a go() method.

The patching is process-wide for the current interpreter. After patching, any new or existing Python function object can call .go(...).

How go() is implemented

The go() method is installed at runtime and is equivalent to:

def go(self, *args, **kwargs):
    import gevent
    greenlet = gevent.spawn(self, *args, **kwargs)
    gevent.sleep(0)  # yield once so spawned work can start promptly
    return greenlet

Notes:

  • go() returns a gevent Greenlet.
  • Use join() or get() when you need to wait for completion.
  • This is cooperative concurrency (greenlets), not native thread-based parallelism.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

goesque-0.1.0.tar.gz (2.7 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

goesque-0.1.0-py3-none-any.whl (2.5 kB view details)

Uploaded Python 3

File details

Details for the file goesque-0.1.0.tar.gz.

File metadata

  • Download URL: goesque-0.1.0.tar.gz
  • Upload date:
  • Size: 2.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for goesque-0.1.0.tar.gz
Algorithm Hash digest
SHA256 6364443b199cc3beabe9953170a355b5d6ff68cd8fcac2df97b6ff6a6d18a5e6
MD5 19e780c1f664758b7ab24106b9f48ba9
BLAKE2b-256 5c6191b6e268209ed9d9558e14a797f897a469ccad12902e45a2522e6b284817

See more details on using hashes here.

Provenance

The following attestation bundles were made for goesque-0.1.0.tar.gz:

Publisher: publish.yml on mliezun/goesque

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file goesque-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: goesque-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 2.5 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for goesque-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 b94954cc8e2c6379063c5a645740fc731002ecd78812f953f064da3e728c0d85
MD5 7878782c96e67c65a10a8130a5077767
BLAKE2b-256 2ac2d4f65476ac3afe9a16e97dff6b51d5cb434a6613a8be35a479329d73677c

See more details on using hashes here.

Provenance

The following attestation bundles were made for goesque-0.1.0-py3-none-any.whl:

Publisher: publish.yml on mliezun/goesque

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page