Skip to content

Modules own many orphaned sockets file descriptors due to the fork() of multiprocessing #1742

@AlyaGomaa

Description

@AlyaGomaa

To reproduce:

  • strace -f -p pid_of_a_slips_module
  • ls -l /proc/<pid_of_a_slips_module>/fd/

you will find modules looping through FDs, listening, then timing out, etc.
this leads to unneccessary CPU usage

Cause:
When creating a redis instance in slips main.py before forking the modules, the fork copies all FDs to the children

Solution: Use a multiprocessing context that uses spawn instead of fork

import multiprocessing as mp

mp.set_start_method("spawn") # instead of fork

Metadata

Metadata

Assignees

No one assigned

    Labels

    Better PerfomanceTasks for making Slips faster and work betterBugA bug that needs to be fixed

    Type

    No type

    Projects

    Status

    Todo

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions