← Back to team overview

launchpad-reviewers team mailing list archive

[Merge] ~cjwatson/launchpad:thread-to-threading into launchpad:master

 

Colin Watson has proposed merging ~cjwatson/launchpad:thread-to-threading into launchpad:master.

Commit message:
Stop using low-level thread module

Requested reviews:
  Launchpad code reviewers (launchpad-reviewers)

For more details, see:
https://code.launchpad.net/~cjwatson/launchpad/+git/launchpad/+merge/379470

It's been renamed to _thread in Python 3.  We can get everything we need from the higher-level threading module instead.
-- 
Your team Launchpad code reviewers is requested to review the proposed merge of ~cjwatson/launchpad:thread-to-threading into launchpad:master.
diff --git a/lib/lp/services/webapp/adapter.py b/lib/lp/services/webapp/adapter.py
index e4cfcc3..727aafc 100644
--- a/lib/lp/services/webapp/adapter.py
+++ b/lib/lp/services/webapp/adapter.py
@@ -9,7 +9,6 @@ import os
 import re
 import sys
 from textwrap import dedent
-import thread
 import threading
 from time import time
 import traceback
@@ -467,7 +466,7 @@ def break_main_thread_db_access(*ignored):
     """
     # Record the ID of the main thread.
     global _main_thread_id
-    _main_thread_id = thread.get_ident()
+    _main_thread_id = threading.current_thread().ident
 
     try:
         getUtility(IStoreSelector).get(MAIN_STORE, DEFAULT_FLAVOR)
@@ -511,7 +510,7 @@ class LaunchpadDatabase(Postgres):
         # Prevent database connections from the main thread if
         # break_main_thread_db_access() has been run.
         if (_main_thread_id is not None and
-            _main_thread_id == thread.get_ident()):
+            _main_thread_id == threading.current_thread().ident):
             raise StormAccessFromMainThread()
 
         try:
diff --git a/lib/lp/services/webapp/publication.py b/lib/lp/services/webapp/publication.py
index 6171ccf..aa32e00 100644
--- a/lib/lp/services/webapp/publication.py
+++ b/lib/lp/services/webapp/publication.py
@@ -9,7 +9,6 @@ __all__ = [
 
 import re
 import sys
-import thread
 import threading
 import time
 import traceback
@@ -250,7 +249,7 @@ class LaunchpadBrowserPublication(
         notify(StartRequestEvent(request))
         request._traversal_start = time.time()
         request._traversal_thread_start = _get_thread_time()
-        threadid = thread.get_ident()
+        threadid = threading.current_thread().ident
         threadrequestfile = open_for_writing(
             'logs/thread-%s.request' % threadid, 'w')
         try: