Created
April 22, 2019 15:12
-
-
Save 6e726d/035f38f1acd23e5fa7bac0a8bc53dea1 to your computer and use it in GitHub Desktop.
Example of py-setproctitle module to help with multiprocessing development.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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