> For the complete documentation index, see [llms.txt](https://docs.hackle.io/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.hackle.io/en/development-guide/python/python-sdk-wsgi-init.md). Agents can also search and read this documentation through its [MCP server](https://docs.hackle.io/~gitbook/mcp).

# WSGI Configuration

If you are using WSGI, you must initialize `hackle_client` after the process has been forked.

## uWSGI

```python
# Step 1: uwsgi.ini 설정
enable-threads = True


# Step 2: app.py 설정
from hackle import hackle
from uwsgidecorators import postfork

class HackleClient:
    client = None

    def init(self):
        if self.client is None:
            self.client = hackle.Client(sdk_key='YOUR_SERVER_SDK_KEY')


hackle_client = HackleClient()


# Step 3: post_fork 설정
@postfork
def post_fork(server, worker):
    hackle_client.init()


# Step 4: hackleClient 사용 시
from app import hackle_client

hackle_client.client.variation(...)
```

## gunicorn

```python
# Step 1: app.py 설정
from hackle import hackle

class HackleClient:
    client = None

    def init(self):
        if self.client is None:
            self.client = hackle.Client(sdk_key='YOUR_SERVER_SDK_KEY')


hackle_client = HackleClient()

def post_fork(server, worker):
    hackle_client.init()


# Step 2: gunicorn.conf.py 설정
from app import post_fork

post_fork = post_fork


# Step 3: hackleClient 사용 시
from app import hackle_client

hackle_client.client.variation(...)
```

## gevent Configuration

If you are changing the internal communication method to non-blocking, such as with gevent monkey patching, you need to delay the instance creation so that the instance is created at the actual call time.

```python
# step 1: gevent monkey patch
import gevent.monkey
gevent.monkey.patch_all()

# step 2: app.py wrapper function
from hackle import hackle

def hackle_wrapper():
    if 'client' not in hackle_wrapper.__dict__:
        hackle_wrapper.client = hackle.Client(sdk_key='YOUR_SERVER_SDK_KEY')
    return hackle_wrapper.client

# step 3: hackleClient 사용 시
from app import hackle_wrapper

hackle_wrapper().variation(...)
```


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation by asking a question.

Perform an HTTP GET request on the following URL with the `ask` and `goal` query parameters:

```
GET https://docs.hackle.io/en/development-guide/python/python-sdk-wsgi-init.md?ask=<question>&goal=<user_goal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is what the user is ultimately trying to achieve, the reason they need the answer. Sharing it helps GitBook give you a better, more relevant answer. A goal is most helpful when it describes the outcome the user wants rather than restating the question. For example, with `ask=how do I create an API token`, a goal like `automate deployments from our CI pipeline` lets GitBook tailor the answer to that use case.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
