Last active
August 6, 2019 09:15
-
-
Save Enteee/dafad1acc020581090ddcedb517e7f77 to your computer and use it in GitHub Desktop.
Demonstrate operating syste dependent behaviour w.r.t static class members in subprocess
This file contains 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
from multiprocessing import Process | |
class C(object): | |
VAR = 'DEFAULT' | |
def print_c(): | |
print(f'C.VAR = {C.VAR}') | |
def main(): | |
print_c() | |
C.VAR = 'CHANGED' | |
print_c() | |
p = Process(target=print_c, daemon=True) | |
p.start() | |
p.join() | |
if __name__ == "__main__": | |
main() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Linux
$ uname -a Linux puddle 4.14.134 #1-NixOS SMP Sun Jul 21 07:04:43 UTC 2019 x86_64 GNU/Linux $ python --version Python 3.6.9 $ python class-variable-in-subprocess.py C.VAR = DEFAULT C.VAR = CHANGED C.VAR = CHANGED
Windows