Skip to content

Trouble Nesting stopit #17

@NoRaincheck

Description

@NoRaincheck

Hi,

I'm having a bit of trouble nesting timeouts. Platforms tested:

  • Windows 10 Pro
  • Mac OSX

My shortest reproducible solution is here:

from stopit import ThreadingTimeout as Timeout
import time

def print_stuff(idx):
    while True:
        time.sleep(1)
        print(idx)


def test_this():
    t0 = time.time()
    for idx in range(5):
        with Timeout(5) as timeout_inner:
            print_stuff(idx)
    return time.time() - t0

with Timeout(10) as timeout_outer:
    res = test_this()

assert res < 15

Where the output is:

0
0
0
0
1
1
1
1
2
2
2
2
3
3
3
3
4
4
4
4
---------------------------------------------------------------------------
AssertionError                            Traceback (most recent call last)
<ipython-input-28-abee5adecac5> in <module>()
     18     res = test_this()
     19 
---> 20 assert res < 15

AssertionError: 

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions