[tor-commits] [flashproxy/master] use with-syntax for locks

infinity0 at torproject.org infinity0 at torproject.org
Mon Oct 28 14:47:40 UTC 2013


commit 7719078521bacddc4c33ccc7e7b0dcd92492ca27
Author: Ximin Luo <infinity0 at gmx.com>
Date:   Mon Oct 7 12:08:45 2013 +0100

    use with-syntax for locks
---
 facilitator/facilitator |    5 +----
 1 file changed, 1 insertion(+), 4 deletions(-)

diff --git a/facilitator/facilitator b/facilitator/facilitator
index cf99141..647e1ed 100755
--- a/facilitator/facilitator
+++ b/facilitator/facilitator
@@ -93,12 +93,9 @@ def safe_str(s):
 
 log_lock = threading.Lock()
 def log(msg):
-    log_lock.acquire()
-    try:
+    with log_lock:
         print >> options.log_file, (u"%s %s" % (time.strftime(LOG_DATE_FORMAT), msg)).encode("UTF-8")
         options.log_file.flush()
-    finally:
-        log_lock.release()
 
 class TCPReg(object):
     def __init__(self, host, port, transports):





More information about the tor-commits mailing list