Show More
@@ -318,6 +318,9 b' class Session(Configurable):' | |||||
318 | with open(new, 'rb') as f: |
|
318 | with open(new, 'rb') as f: | |
319 | self.key = f.read().strip() |
|
319 | self.key = f.read().strip() | |
320 |
|
320 | |||
|
321 | # for protecting against sends from forks | |||
|
322 | pid = Integer() | |||
|
323 | ||||
321 | # serialization traits: |
|
324 | # serialization traits: | |
322 |
|
325 | |||
323 | pack = Any(default_packer) # the actual packer function |
|
326 | pack = Any(default_packer) # the actual packer function | |
@@ -341,6 +344,7 b' class Session(Configurable):' | |||||
341 | Containers larger than this are pickled outright. |
|
344 | Containers larger than this are pickled outright. | |
342 | """ |
|
345 | """ | |
343 | ) |
|
346 | ) | |
|
347 | ||||
344 |
|
348 | |||
345 | def __init__(self, **kwargs): |
|
349 | def __init__(self, **kwargs): | |
346 | """create a Session object |
|
350 | """create a Session object | |
@@ -382,6 +386,7 b' class Session(Configurable):' | |||||
382 | self.none = self.pack({}) |
|
386 | self.none = self.pack({}) | |
383 | # ensure self._session_default() if necessary, so bsession is defined: |
|
387 | # ensure self._session_default() if necessary, so bsession is defined: | |
384 | self.session |
|
388 | self.session | |
|
389 | self.pid = os.getpid() | |||
385 |
|
390 | |||
386 | @property |
|
391 | @property | |
387 | def msg_id(self): |
|
392 | def msg_id(self): | |
@@ -568,7 +573,10 b' class Session(Configurable):' | |||||
568 | else: |
|
573 | else: | |
569 | msg = self.msg(msg_or_type, content=content, parent=parent, |
|
574 | msg = self.msg(msg_or_type, content=content, parent=parent, | |
570 | header=header, metadata=metadata) |
|
575 | header=header, metadata=metadata) | |
571 |
|
576 | if not os.getpid() == self.pid: | ||
|
577 | io.rprint("WARNING: attempted to send message from fork") | |||
|
578 | io.rprint(msg) | |||
|
579 | return | |||
572 | buffers = [] if buffers is None else buffers |
|
580 | buffers = [] if buffers is None else buffers | |
573 | to_send = self.serialize(msg, ident) |
|
581 | to_send = self.serialize(msg, ident) | |
574 | to_send.extend(buffers) |
|
582 | to_send.extend(buffers) |
General Comments 0
You need to be logged in to leave comments.
Login now