Patchwork keepalive: switch from thread to threading module

login
register
mail settings
Submitter Pulkit Goyal
Date July 1, 2016, 1:47 p.m.
Message ID <aa785df5b4ab3e8ca9f7.1467380877@pulkit-goyal>
Download mbox | patch
Permalink /patch/15710/
State Accepted
Headers show

Comments

Pulkit Goyal - July 1, 2016, 1:47 p.m.
# HG changeset patch
# User Pulkit Goyal <7895pulkit@gmail.com>
# Date 1467380836 -19800
#      Fri Jul 01 19:17:16 2016 +0530
# Node ID aa785df5b4ab3e8ca9f7edf8385f914bf7b7c415
# Parent  752f11e6e60f6214335dd761e6bb045d63747bbb
keepalive: switch from thread to threading module

The thread module in py3 is renamed to _thread, but we can use
 the high level threading module instead.
Martijn Pieters - July 1, 2016, 1:50 p.m.
On 1 July 2016 at 14:47, Pulkit Goyal <7895pulkit@gmail.com> wrote:
> # HG changeset patch
> # User Pulkit Goyal <7895pulkit@gmail.com>
> # Date 1467380836 -19800
> #      Fri Jul 01 19:17:16 2016 +0530
> # Node ID aa785df5b4ab3e8ca9f7edf8385f914bf7b7c415
> # Parent  752f11e6e60f6214335dd761e6bb045d63747bbb
> keepalive: switch from thread to threading module
>
> The thread module in py3 is renamed to _thread, but we can use
>  the high level threading module instead.
>

Thanks! LGTM :-)


> diff -r 752f11e6e60f -r aa785df5b4ab mercurial/keepalive.py
> --- a/mercurial/keepalive.py    Tue Jun 28 16:01:53 2016 +0530
> +++ b/mercurial/keepalive.py    Fri Jul 01 19:17:16 2016 +0530
> @@ -113,7 +113,7 @@
>  import hashlib
>  import socket
>  import sys
> -import thread
> +import threading
>
>  from . import (
>      util,
> @@ -135,7 +135,7 @@
>        * keep track of all existing
>        """
>      def __init__(self):
> -        self._lock = thread.allocate_lock()
> +        self._lock = threading.Lock()
>          self._hostmap = {} # map hosts to a list of connections
>          self._connmap = {} # map connections to host
>          self._readymap = {} # map connection to ready state
> _______________________________________________
> Mercurial-devel mailing list
> Mercurial-devel@mercurial-scm.org
> https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel
Yuya Nishihara - July 1, 2016, 2:39 p.m.
On Fri, 01 Jul 2016 19:17:57 +0530, Pulkit Goyal wrote:
> # HG changeset patch
> # User Pulkit Goyal <7895pulkit@gmail.com>
> # Date 1467380836 -19800
> #      Fri Jul 01 19:17:16 2016 +0530
> # Node ID aa785df5b4ab3e8ca9f7edf8385f914bf7b7c415
> # Parent  752f11e6e60f6214335dd761e6bb045d63747bbb
> keepalive: switch from thread to threading module

Queued, thanks.

Patch

diff -r 752f11e6e60f -r aa785df5b4ab mercurial/keepalive.py
--- a/mercurial/keepalive.py	Tue Jun 28 16:01:53 2016 +0530
+++ b/mercurial/keepalive.py	Fri Jul 01 19:17:16 2016 +0530
@@ -113,7 +113,7 @@ 
 import hashlib
 import socket
 import sys
-import thread
+import threading
 
 from . import (
     util,
@@ -135,7 +135,7 @@ 
       * keep track of all existing
       """
     def __init__(self):
-        self._lock = thread.allocate_lock()
+        self._lock = threading.Lock()
         self._hostmap = {} # map hosts to a list of connections
         self._connmap = {} # map connections to host
         self._readymap = {} # map connection to ready state