Gentoo Archives: gentoo-commits

From: "André Erdmann" <dywi@×××××××.de>
To: gentoo-commits@l.g.o
Subject: [gentoo-commits] proj/R_overlay:master commit in: roverlay/depres/
Date: Mon, 02 Jul 2012 16:52:58
Message-Id: 1341247644.5092211ac965d6f24d1a665c7aa7ce0ee292a4f1.dywi@gentoo
1 commit: 5092211ac965d6f24d1a665c7aa7ce0ee292a4f1
2 Author: André Erdmann <dywi <AT> mailerd <DOT> de>
3 AuthorDate: Mon Jul 2 16:47:24 2012 +0000
4 Commit: André Erdmann <dywi <AT> mailerd <DOT> de>
5 CommitDate: Mon Jul 2 16:47:24 2012 +0000
6 URL: http://git.overlays.gentoo.org/gitweb/?p=proj/R_overlay.git;a=commit;h=5092211a
7
8 depres channels: lock id generator usage
9
10 modified: roverlay/depres/communication.py
11
12 ---
13 roverlay/depres/communication.py | 10 +++++-----
14 1 files changed, 5 insertions(+), 5 deletions(-)
15
16 diff --git a/roverlay/depres/communication.py b/roverlay/depres/communication.py
17 index 14d6193..daeb79e 100644
18 --- a/roverlay/depres/communication.py
19 +++ b/roverlay/depres/communication.py
20 @@ -6,13 +6,11 @@ import threading
21 import sys
22
23 def channel_counter ():
24 - lock = threading.Lock()
25 last_id = long ( -1 ) if sys.version_info < ( 3, ) else int ( -1 )
26
27 while True:
28 - with lock:
29 - last_id += 1
30 - yield last_id
31 + last_id += 1
32 + yield last_id
33
34
35 class DependencyResolverListener ( object ):
36 @@ -59,6 +57,7 @@ class DependencyResolverListener ( object ):
37
38 class DependencyResolverChannel ( object ):
39
40 + id_gen_lock = threading.Lock()
41 id_generator = channel_counter()
42
43 def __init__ ( self, main_resolver ):
44 @@ -73,7 +72,8 @@ class DependencyResolverChannel ( object ):
45 #super ( DependencyResolverChannel, self ) . __init__ ()
46 # channel identifiers must be unique even when the channel has been
47 # deleted (id does not guarantee that)
48 - self.ident = next ( DependencyResolverChannel.id_generator )
49 + with DependencyResolverChannel.id_gen_lock:
50 + self.ident = next ( DependencyResolverChannel.id_generator )
51 self._depres_master = main_resolver
52 # --- end of __init__ (...) ---