Edit File by line
/home/barbar84/www/wp-conte.../plugins/sujqvwi/ShExBy/shex_roo.../proc/self/root/lib64/python3....
File: dummy_threading.py
"""Faux ``threading`` version using ``dummy_thread`` instead of ``thread``.
[0] Fix | Delete
[1] Fix | Delete
The module ``_dummy_threading`` is added to ``sys.modules`` in order
[2] Fix | Delete
to not have ``threading`` considered imported. Had ``threading`` been
[3] Fix | Delete
directly imported it would have made all subsequent imports succeed
[4] Fix | Delete
regardless of whether ``_thread`` was available which is not desired.
[5] Fix | Delete
[6] Fix | Delete
"""
[7] Fix | Delete
from sys import modules as sys_modules
[8] Fix | Delete
[9] Fix | Delete
import _dummy_thread
[10] Fix | Delete
[11] Fix | Delete
# Declaring now so as to not have to nest ``try``s to get proper clean-up.
[12] Fix | Delete
holding_thread = False
[13] Fix | Delete
holding_threading = False
[14] Fix | Delete
holding__threading_local = False
[15] Fix | Delete
[16] Fix | Delete
try:
[17] Fix | Delete
# Could have checked if ``_thread`` was not in sys.modules and gone
[18] Fix | Delete
# a different route, but decided to mirror technique used with
[19] Fix | Delete
# ``threading`` below.
[20] Fix | Delete
if '_thread' in sys_modules:
[21] Fix | Delete
held_thread = sys_modules['_thread']
[22] Fix | Delete
holding_thread = True
[23] Fix | Delete
# Must have some module named ``_thread`` that implements its API
[24] Fix | Delete
# in order to initially import ``threading``.
[25] Fix | Delete
sys_modules['_thread'] = sys_modules['_dummy_thread']
[26] Fix | Delete
[27] Fix | Delete
if 'threading' in sys_modules:
[28] Fix | Delete
# If ``threading`` is already imported, might as well prevent
[29] Fix | Delete
# trying to import it more than needed by saving it if it is
[30] Fix | Delete
# already imported before deleting it.
[31] Fix | Delete
held_threading = sys_modules['threading']
[32] Fix | Delete
holding_threading = True
[33] Fix | Delete
del sys_modules['threading']
[34] Fix | Delete
[35] Fix | Delete
if '_threading_local' in sys_modules:
[36] Fix | Delete
# If ``_threading_local`` is already imported, might as well prevent
[37] Fix | Delete
# trying to import it more than needed by saving it if it is
[38] Fix | Delete
# already imported before deleting it.
[39] Fix | Delete
held__threading_local = sys_modules['_threading_local']
[40] Fix | Delete
holding__threading_local = True
[41] Fix | Delete
del sys_modules['_threading_local']
[42] Fix | Delete
[43] Fix | Delete
import threading
[44] Fix | Delete
# Need a copy of the code kept somewhere...
[45] Fix | Delete
sys_modules['_dummy_threading'] = sys_modules['threading']
[46] Fix | Delete
del sys_modules['threading']
[47] Fix | Delete
sys_modules['_dummy__threading_local'] = sys_modules['_threading_local']
[48] Fix | Delete
del sys_modules['_threading_local']
[49] Fix | Delete
from _dummy_threading import *
[50] Fix | Delete
from _dummy_threading import __all__
[51] Fix | Delete
[52] Fix | Delete
finally:
[53] Fix | Delete
# Put back ``threading`` if we overwrote earlier
[54] Fix | Delete
[55] Fix | Delete
if holding_threading:
[56] Fix | Delete
sys_modules['threading'] = held_threading
[57] Fix | Delete
del held_threading
[58] Fix | Delete
del holding_threading
[59] Fix | Delete
[60] Fix | Delete
# Put back ``_threading_local`` if we overwrote earlier
[61] Fix | Delete
[62] Fix | Delete
if holding__threading_local:
[63] Fix | Delete
sys_modules['_threading_local'] = held__threading_local
[64] Fix | Delete
del held__threading_local
[65] Fix | Delete
del holding__threading_local
[66] Fix | Delete
[67] Fix | Delete
# Put back ``thread`` if we overwrote, else del the entry we made
[68] Fix | Delete
if holding_thread:
[69] Fix | Delete
sys_modules['_thread'] = held_thread
[70] Fix | Delete
del held_thread
[71] Fix | Delete
else:
[72] Fix | Delete
del sys_modules['_thread']
[73] Fix | Delete
del holding_thread
[74] Fix | Delete
[75] Fix | Delete
del _dummy_thread
[76] Fix | Delete
del sys_modules
[77] Fix | Delete
[78] Fix | Delete
It is recommended that you Edit text format, this type of Fix handles quite a lot in one request
Function