self = <contextlib.ExitStack object at 0x7f154003b358>
exc_details = (<class 'ValueError'>, ValueError("<Token var=<ContextVar name='flask.request_ctx' at 0x7f154560be08> at 0x7f152a4300d8> was created in a different Context"), <traceback object at 0x7f152a437bc8>)
received_exc = False
_fix_exception_context = <function ExitStack.__exit__.<locals>._fix_exception_context at 0x7f152a364bf8>
suppressed_exc = False
def __exit__(self, *exc_details):
received_exc = exc_details[0] is not None
# We manipulate the exception state so it behaves as though
# we were actually nesting multiple with statements
frame_exc = sys.exc_info()[1]
def _fix_exception_context(new_exc, old_exc):
# Context may not be correct, so find the end of the chain
while 1:
exc_context = new_exc.__context__
if exc_context is old_exc:
# Context is already set correctly (see issue 20317)
return
if exc_context is None or exc_context is frame_exc:
break
new_exc = exc_context
# Change the end of the chain to point to the exception
# we expect it to reference
new_exc.__context__ = old_exc
# Callbacks are invoked in LIFO order to match the behaviour of
# nested context managers
suppressed_exc = False
pending_raise = False
while self._exit_callbacks:
is_sync, cb = self._exit_callbacks.pop()
assert is_sync
try:
> if cb(*exc_details):
/usr/lib/python3.7/contextlib.py:496:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
exc_type = None, exc = None, tb = None
def _exit_wrapper(exc_type, exc, tb):
> return cm_exit(cm, exc_type, exc, tb)
/usr/lib/python3.7/contextlib.py:377:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
self = <flask.ctx.AppContext object at 0x7f152a4264a8>, exc_type = None
exc_value = None, tb = None
def __exit__(
self,
exc_type: t.Optional[type],
exc_value: t.Optional[BaseException],
tb: t.Optional[TracebackType],
) -> None:
> self.pop(exc_value)
.tox/py3/lib/python3.7/site-packages/flask/ctx.py:275:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
self = <flask.ctx.AppContext object at 0x7f152a4264a8>, exc = None
def pop(self, exc: t.Optional[BaseException] = _sentinel) -> None: # type: ignore
"""Pops the app context."""
try:
if len(self._cv_tokens) == 1:
if exc is _sentinel:
exc = sys.exc_info()[1]
self.app.do_teardown_appcontext(exc)
finally:
ctx = _cv_app.get()
> _cv_app.reset(self._cv_tokens.pop())
E ValueError: <Token var=<ContextVar name='flask.app_ctx' at 0x7f154560bdb0> at 0x7f152a430120> was created in a different Context
.tox/py3/lib/python3.7/site-packages/flask/ctx.py:256: ValueError
During handling of the above exception, another exception occurred:
self = <swh.indexer.tests.storage.test_storage.TestIndexerStorageContentMetadata object at 0x7f1542fba588>
swh_indexer_storage_with_data = (<RemoteStorage url=mock://example.com/>, {'tools': {'swh-metadata-translator': {'id': 1, 'name': 'swh-metadata-transl...Row(indexer_configuration_id=7, tool=None, id=b'=<\x9f1\xecV,\xd4\xb3\xf7\xa0Yg\xa8]]\xc5\xa0O\x18', license=b'MIT')]})
def test_add_deadlock(
self, swh_indexer_storage_with_data: Tuple[IndexerStorageInterface, Any]
) -> None:
storage, data = swh_indexer_storage_with_data
etype = self.endpoint_type
tool = data.tools[self.tool_name]
hashes = [
hash_to_bytes("34973274ccef6ab4dfaaf86599792fa9c3fe4{:03d}".format(i))
for i in range(1000)
]
data_v1 = [
self.row_class.from_dict(
{
"id": hash_,
**self.example_data[0],
"indexer_configuration_id": tool["id"],
}
)
for hash_ in hashes
]
data_v2 = [
self.row_class.from_dict(
{
"id": hash_,
**self.example_data[1],
"indexer_configuration_id": tool["id"],
}
)
for hash_ in hashes
]
# Remove one item from each, so that both queries have to succeed for
# all items to be in the DB.
data_v2a = data_v2[1:]
data_v2b = list(reversed(data_v2[0:-1]))
# given
endpoint(storage, etype, "add")(data_v1)
# when
actual_data = sorted(
endpoint(storage, etype, "get")(hashes),
key=lambda x: x.id,
)
expected_data_v1 = [
self.row_class.from_dict(
{"id": hash_, **self.example_data[0], "tool": tool}
)
for hash_ in hashes
]
# then
assert actual_data == expected_data_v1
# given
def f1() -> None:
endpoint(storage, etype, "add")(data_v2a)
def f2() -> None:
endpoint(storage, etype, "add")(data_v2b)
t1 = threading.Thread(target=f1)
t2 = threading.Thread(target=f2)
t2.start()
t1.start()
t1.join()
t2.join()
actual_data = sorted(
> endpoint(storage, etype, "get")(hashes),
key=lambda x: x.id,
)
.tox/py3/lib/python3.7/site-packages/swh/indexer/tests/storage/test_storage.py:267:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
.tox/py3/lib/python3.7/site-packages/swh/core/api/__init__.py:183: in meth_
return self._post(meth._endpoint_path, post_data)
.tox/py3/lib/python3.7/site-packages/swh/core/api/__init__.py:272: in _post
**opts,
.tox/py3/lib/python3.7/site-packages/swh/core/api/__init__.py:254: in raw_verb
return getattr(self.session, verb)(self._url(endpoint), **opts)
.tox/py3/lib/python3.7/site-packages/requests/sessions.py:635: in post
return self.request("POST", url, data=data, json=json, **kwargs)
.tox/py3/lib/python3.7/site-packages/requests/sessions.py:587: in request
resp = self.send(prep, **send_kwargs)
.tox/py3/lib/python3.7/site-packages/requests/sessions.py:701: in send
r = adapter.send(request, **kwargs)
.tox/py3/lib/python3.7/site-packages/swh/core/pytest_plugin.py:300: in send
data=request.body,
.tox/py3/lib/python3.7/site-packages/flask/testing.py:221: in open
self._context_stack.close()
/usr/lib/python3.7/contextlib.py:519: in close
self.__exit__(None, None, None)
/usr/lib/python3.7/contextlib.py:511: in __exit__
raise exc_details[1]
/usr/lib/python3.7/contextlib.py:496: in __exit__
if cb(*exc_details):
/usr/lib/python3.7/contextlib.py:377: in _exit_wrapper
return cm_exit(cm, exc_type, exc, tb)
.tox/py3/lib/python3.7/site-packages/flask/ctx.py:432: in __exit__
self.pop(exc_value)
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
self = <RequestContext 'mock://example.com/content_metadata/add' [POST] of swh.indexer.storage.api.server>
exc = ValueError("<Token var=<ContextVar name='flask.app_ctx' at 0x7f154560bdb0> at 0x7f152a430120> was created in a different Context")
def pop(self, exc: t.Optional[BaseException] = _sentinel) -> None: # type: ignore
"""Pops the request context and unbinds it by doing that. This will
also trigger the execution of functions registered by the
:meth:`~flask.Flask.teardown_request` decorator.
.. versionchanged:: 0.9
Added the `exc` argument.
"""
clear_request = len(self._cv_tokens) == 1
try:
if clear_request:
if exc is _sentinel:
exc = sys.exc_info()[1]
self.app.do_teardown_request(exc)
request_close = getattr(self.request, "close", None)
if request_close is not None:
request_close()
finally:
ctx = _cv_request.get()
token, app_ctx = self._cv_tokens.pop()
> _cv_request.reset(token)
E ValueError: <Token var=<ContextVar name='flask.request_ctx' at 0x7f154560be08> at 0x7f152a4300d8> was created in a different Context
.tox/py3/lib/python3.7/site-packages/flask/ctx.py:407: ValueError
TEST RESULT
TEST RESULT
- Run At
- Aug 3 2022, 2:50 PM