apache / apache/rocketmq-client-python

Producer can not be started in UWSGI, and raises a rocketmq.exceptions.ProducerStartFailed

Open
#140 0 comments 0 reactions 0 assignees View on GitHub
Dominant language
Python
Stars
305
Forks
98
PR merge metrics
No merged PRs in 30d

Description

My application is deveplped with Django which provides a Web API service and runs over UWSGI. The real code is as follows:

```python
mq_locals = {}

def get_producer() -> Producer:
if 'producer' not in mq_locals:
producer = Producer('XXX')
producer.set_namesrv_addr(settings.ODMS_CONFIG['name_server']) # pylint: disable=E1101
producer.start()

mq_locals['producer'] = producer

return mq_locals['producer']
```

But the application raises a `rocketmq.exceptions.ProducerStartFailed: boost::thread_resource_error: Resource temporarily unavailable` when the `get_producer` method is called.

The version of `rocketmq-client-python` and `rocketmq` are **2.0.0** and **0.4.4** respectively. And the OS is Ubuntu. The Detailed log is as follows.

```bash
Traceback (most recent call last):
File "/usr/local/lib/python3.7/site-packages/django/core/handlers/exception.py", line 34, in inner
response = get_response(request)
File "/usr/local/lib/python3.7/site-packages/django/core/handlers/base.py", line 115, in _get_response
response = self.process_exception_by_middleware(e, request)
File "/usr/local/lib/python3.7/site-packages/django/core/handlers/base.py", line 113, in _get_response
response = wrapped_callback(request, *callback_args, **callback_kwargs)
File "/usr/local/lib/python3.7/site-packages/django/views/decorators/http.py", line 40, in inner
return func(request, *args, **kwargs)
File "/dc_utils3/dc_account_md/decorators.py", line 29, in _wrapped_view
return view_func(request, *args, **kwargs)
File "./odms/views/submission_approve.py", line 64, in submission_approve
send_approve_message(submission.archive_id, mq_srv.APPROVE_STATUS_YES, comment)
File "./odms/views/submission_approve.py", line 74, in send_approve_message
mq_srv.send_approve_message(archive_id, approve_status, comment)
File "./odms/services/mq.py", line 58, in send_approve_message
echo_producer = get_producer()
File "./odms/services/mq.py", line 30, in get_producer
producer.start()
File "/usr/local/lib/python3.7/site-packages/rocketmq/client.py", line 329, in start
ffi_check(dll.StartProducer(self._handle))
File "/usr/local/lib/python3.7/site-packages/rocketmq/exceptions.py", line 27, in ffi_check
raise exc_cls(msg)
rocketmq.exceptions.ProducerStartFailed: boost::thread_resource_error: Resource temporarily unavailable
```

In addition, the `get_producer` method is call normally in Django console.

![image](https://github.com/apache/rocketmq-client-python/assets/12782530/4b5aedba-416d-40fc-bbc1-8ea25ad88765)

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.