Skip to content
This repository has been archived by the owner on Apr 22, 2020. It is now read-only.

concurrency: add a pointer to the exception type the ME is a type of;… #97

Merged
merged 1 commit into from
Jul 22, 2018

Conversation

koreno
Copy link
Contributor

@koreno koreno commented Jul 19, 2018

… support ME pickling

@koreno koreno self-assigned this Jul 19, 2018
@idanarye
Copy link

I propose to replace the test with something like this:

def test_multiexception_pickling():
    import pickle
    import multiprocessing

    def fail_and_dump(queue):
        try:
            MultiObject(range(5)).call(_ExceptionForPicklingTest.throw)
        except MultiException[ArithmeticError] as exc:
            p = pickle.dumps(exc)
            queue.put_nowait(p)

    queue = multiprocessing.Queue(1)
    process = multiprocessing.Process(target=fail_and_dump, args=(queue,))
    process.start()
    process.join()
    p = queue.get_nowait()

    exc = pickle.loads(p)
    assert isinstance(exc, MultiException[_ExceptionForPicklingTest])
    assert exc.common_type is _ExceptionForPicklingTest
    assert exc.exceptions[0].args == (0,)
    assert exc.exceptions[1:] == [None, None, None, None]

By using the multiprocessing module we can simulate the multiprocess environment this feature is designed for without depending on binary literals.

@koreno koreno force-pushed the multiexc-with-supertype branch 2 times, most recently from a28ffd0 to d4b6536 Compare July 20, 2018 13:33
@koreno koreno merged commit a304c3f into master Jul 22, 2018
@YuvalEvron YuvalEvron deleted the multiexc-with-supertype branch August 6, 2019 08:33
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants