django-background-tasks icon indicating copy to clipboard operation
django-background-tasks copied to clipboard

Windows bug: process_task "hangs" after two checks

Open Moon-developer opened this issue 5 years ago • 1 comments

I have noticed that on windows when I run process_tasks it tends to hang after it's second loop of checking for new tasks to process. I am not sure what is causing this issue.

Context: I create custom tasks that will check a set amount of external urls/endpoints to see if the service/website/api is accessible and then send a message to a redis-server which then gets pulled client side for a "live" update of certain applications status.

Example:

@background
def check_endpoint(endpoint_lst):
    status_data = {}
    for endpoint in endpoint_lst:
        status_data[endpoint] = check_status(endpoint)
    sync.async_to_sync(channel_layer.group_send)(
        str("notify"),  # Channel Name, Should always be string
        {
            "type": "notify",  # Custom Function written in the consumers.py
            "status_data": status_data,
        },
    }
    time.sleep(60 * 10)
    check_endpoint(endpoint_lst)

I call it's self again at the end to create a new task, I found that if I use the decorator to repeat my tasks it locks pid all the time. I am connected to a mssql server if this helps to know about too. and I have 24 tasks to process. ASYNC is set to True and thread amount set to 4 in settings.py

I have been stuck with this issue for awhile now and could really use some help.

Moon-developer avatar Nov 14 '19 13:11 Moon-developer

Were you able to find a solution to this?

pastorhudson avatar Feb 19 '24 18:02 pastorhudson