Skip to content

Commit 55c71a3

Browse files
author
Thomas Grainger
committed
use a lock to make force_reset thread safe
Fixes kevin1024#295, Fixes kevin1024#212
1 parent 70f4707 commit 55c71a3

File tree

1 file changed

+5
-0
lines changed

1 file changed

+5
-0
lines changed

vcr/patch.py

+5
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
'''Utilities for patching in cassettes'''
22
import functools
33
import itertools
4+
import threading
45

56
from .compat import contextlib, mock
67
from .stubs import VCRHTTPConnection, VCRHTTPSConnection
@@ -447,9 +448,13 @@ def reset_patchers():
447448
)
448449

449450

451+
_force_reset_lock = threading.RLock()
452+
453+
450454
@contextlib.contextmanager
451455
def force_reset():
452456
with contextlib.ExitStack() as exit_stack:
457+
exit_stack.enter_context(_force_reset_lock)
453458
for patcher in reset_patchers():
454459
exit_stack.enter_context(patcher)
455460
yield

0 commit comments

Comments
 (0)