Metadata-Version: 2.4
Name: goesque
Version: 0.1.0
Summary: Patch Python function objects with a gevent-backed go() helper.
Requires-Python: >=3.10
Description-Content-Type: text/markdown
Requires-Dist: gevent
Provides-Extra: dev
Requires-Dist: pytest>=8.0; extra == "dev"

# goesque

[![Tests](https://github.com/mliezun/goesque/actions/workflows/tests.yml/badge.svg)](https://github.com/mliezun/goesque/actions/workflows/tests.yml)

`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

```python
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:

```python
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.
