File tree Expand file tree Collapse file tree 3 files changed +29
-17
lines changed Expand file tree Collapse file tree 3 files changed +29
-17
lines changed Original file line number Diff line number Diff line change @@ -30,6 +30,18 @@ Quick Example
30
30
session.write_transaction(add_friends, " Arthur" , " Merlin" )
31
31
session.read_transaction(print_friends, " Arthur" )
32
32
33
+ Logging
34
+ =============
35
+ The driver provides a built-in logging. The following example code enables debug logging and prints out logs at stdout:
36
+
37
+ .. code-block :: python
38
+
39
+ from neo4j.util import watch
40
+ import logging
41
+ from sys import stdout
42
+
43
+ watch(" neo4j.bolt" , logging.DEBUG , stdout)
44
+
33
45
34
46
Installation
35
47
============
Original file line number Diff line number Diff line change @@ -507,10 +507,16 @@ def close(self):
507
507
""" Close all connections and empty the pool.
508
508
This method is thread safe.
509
509
"""
510
- with self .lock :
511
- self ._closed = True
512
- for address in list (self .connections ):
513
- self .remove (address )
510
+ if self ._closed :
511
+ return
512
+ try :
513
+ with self .lock :
514
+ if not self ._closed :
515
+ self ._closed = True
516
+ for address in list (self .connections ):
517
+ self .remove (address )
518
+ except TypeError as e :
519
+ pass
514
520
515
521
def closed (self ):
516
522
""" Return :const:`True` if this pool is closed, :const:`False`
Original file line number Diff line number Diff line change 41
41
RETRY_DELAY_MULTIPLIER = 2.0
42
42
RETRY_DELAY_JITTER_FACTOR = 0.2
43
43
44
+
44
45
def last_bookmark (b0 , b1 ):
45
46
""" Return the latest of two bookmarks by looking for the maximum
46
47
integer value following the last colon in the bookmark string.
@@ -141,10 +142,7 @@ class Driver(object):
141
142
#: Indicator of driver closure.
142
143
_closed = False
143
144
144
- _lock = None
145
-
146
145
def __init__ (self , pool , ** config ):
147
- self ._lock = RLock ()
148
146
self ._pool = pool
149
147
self ._max_retry_time = config .get ("max_retry_time" , default_config ["max_retry_time" ])
150
148
@@ -185,18 +183,14 @@ def close(self):
185
183
""" Shut down, closing any open connections that were spawned by
186
184
this Driver.
187
185
"""
188
- if self ._lock is None :
189
- return
190
- with self ._lock :
191
- if not self ._closed :
192
- self ._closed = True
193
- if self ._pool is not None :
194
- self ._pool .close ()
195
- self ._pool = None
186
+ if not self ._closed :
187
+ self ._closed = True
188
+ if self ._pool is not None :
189
+ self ._pool .close ()
190
+ self ._pool = None
196
191
197
192
def closed (self ):
198
- with self ._lock :
199
- return self ._closed
193
+ return self ._closed
200
194
201
195
202
196
class Session (object ):
You can’t perform that action at this time.
0 commit comments