Skip to content

Channels and web concurrency #1821

@dan-developer

Description

@dan-developer

Good Morning.

I'm doing the following calculations in a view to use multiple processors:

cpus = multiprocessing.cpu_count()
processes = cpus - 2 if cpus > 2 else 1

with multiprocessing.Pool(processes=processes) as pool: 

    ...

    results = pool.starmap(_calculate_sf, data_to_simulate)

    pool.close()
    pool.join()

return redirect...

But there is a problem when I activate the "channels" app, which is: while there is a calculation running, new connections (another browser and ips (another clients)) are not accepted http processing (request -> processing -> response). It is waiting, while it does not finish the calculation, it does not respond to more connections. I had to return to the WSGI application which the problem does not occur.

  • Ubuntu 18.04, Ubuntu 20.04 and MacOS 12.2 with Docker Desktop.
  • Relevant requirements:
daphne==3.0.1
Django==3.2
django-celery-results==2.0.0
channels==3.0.2
channels-redis==3.2.0
  • Calculate without freeze other connections.
  • How you're running Channels: runserver
  • No errors.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions