Skip to content
This repository was archived by the owner on Jan 23, 2024. It is now read-only.

Commit 513b8aa

Browse files
committed
Do a dummy call to strptime at startup to work around a concurrency issue on the first call to strptime.
See http://bugs.python.org/issue7980 for discussion of the Python bug. ------------- Created by MOE: https://github.com/google/moe MOE_MIGRATED_REVID=143828002
1 parent 7b370d0 commit 513b8aa

1 file changed

Lines changed: 7 additions & 0 deletions

File tree

src/googleclouddebugger/python_breakpoint.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,13 @@
6666
'refersTo': 'BREAKPOINT_CONDITION',
6767
'description': {'format': MUTABLE_CONDITION}})])
6868

69+
# The implementation of datetime.strptime imports an undocumented module called
70+
# _strptime. If it happens at the wrong time, we can get an exception about
71+
# trying to import while another thread holds the import lock. This dummy call
72+
# to strptime ensures that the module is loaded at startup.
73+
# See http://bugs.python.org/issue7980 for discussion of the Python bug.
74+
datetime.strptime('2017-01-01', '%Y-%m-%d')
75+
6976

7077
class PythonBreakpoint(object):
7178
"""Handles a single Python breakpoint.

0 commit comments

Comments
 (0)