rq / django-rq

A simple app that provides django integration for RQ (Redis Queue)
MIT License
1.81k stars 282 forks source link

RQ Job Terminated Unexpectedly #625

Open rcthakuri opened 10 months ago

rcthakuri commented 10 months ago

I have defined the rq task on module task.py as:

import django_rq
import logging
import requests

log = logging.getLogger(__name__)

def req_call():
    url = 'https://jsonplaceholder.typicode.com/posts'
    response = requests.get(url)
    return response

@django_rq.job('default')
def test_request_call_on_rq_job():
    response = req_call()
    log.warning(f'REQUEST's RESPONSE {response.json()}')

When I've offloaded task in another module as:

if __name__ == '__main__':  # rq job test
    log.setLevel(logging.DEBUG)
    test_post_request_on_rq_job.delay()

I am getting error as:

[INFO] *** Listening on default...  [worker:702]
[INFO] default: rq_test_module.tasks.test_request_call_on_rq_job() (676c1945-9e05-4245-aeb2-65100cdb4169)  [worker:875]
[WARNING] Moving job to FailedJobRegistry (Work-horse terminated unexpectedly; waitpid returned 11 (signal 11); )  [worker:1114]

I then started doing debugging, then I saw error encounters as soon as the job task tried executing the request call i.e. requests.get(url) And if I remove the request call from the job, then it executed gracefully without any errors.

Signal 11 indicates a segmentation fault, I suspect something related to memory but not quite sure about it.

So anyone here encountered similar issue and workaround for this :)

ramchandra-st commented 10 months ago

I think I found the cause of the request being not executed gracefully on rq. I bet it was due to **https://github.com/python/cpython/blob/main/Lib/urllib/request.py#L2619 not able to find that library. So I just skipped the way to reach there by setting NO_PROXY env to the URL I am trying to request.

I guess, we can close this, now.

zanderle commented 2 months ago

I had this issue to, and found a similar explanation to yours. So simply setting export NO_PROXY=* resolved my issue.