Skip to content

Instantly share code, notes, and snippets.

@6e726d
Created April 22, 2019 15:12
Show Gist options
  • Save 6e726d/035f38f1acd23e5fa7bac0a8bc53dea1 to your computer and use it in GitHub Desktop.
Save 6e726d/035f38f1acd23e5fa7bac0a8bc53dea1 to your computer and use it in GitHub Desktop.
Example of py-setproctitle module to help with multiprocessing development.
#!/usr/bin/env python3
import time
import random
from multiprocessing import Process
from setproctitle import setproctitle
class A(Process):
def run(self):
setproctitle(self.__class__.__name__)
time.sleep(60)
class B(Process):
def run(self):
setproctitle(self.__class__.__name__)
for i in range(10):
time.sleep(10)
class C(Process):
def run(self):
setproctitle(self.__class__.__name__)
time.sleep(random.randint(60, 300))
if __name__ == "__main__":
for i in range(10):
c = random.choice([A(), B(), C()])
c.start()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment