4444
4545CRATE_CONFIG_ERROR = 'crate_config must point to a folder or to a file named "crate.yml"'
4646HTTP_ADDRESS_RE = re .compile (
47- '.*\[(http|.*HttpServer.*)\s*] \[.*\] .*'
47+ r '.*\[(http|.*HttpServer.*)\s*] \[.*\] .*'
4848 'publish_address {'
49- '(?:inet\[[\w\d\.-]*/|\[)?'
50- '(?:[\w\d\.-]+/)?'
51- '(?P<addr>[\d\.:]+)'
52- '(?:\])?'
49+ r '(?:inet\[[\w\d\.-]*/|\[)?'
50+ r '(?:[\w\d\.-]+/)?'
51+ r '(?P<addr>[\d\.:]+)'
52+ r '(?:\])?'
5353 '}'
5454)
5555
@@ -131,7 +131,6 @@ class CrateLayer(object):
131131
132132 tmpdir = tempfile .gettempdir ()
133133 wait_interval = 0.2
134- conn_pool = urllib3 .PoolManager (num_pools = 1 )
135134
136135 @staticmethod
137136 def from_uri (uri ,
@@ -157,7 +156,7 @@ def from_uri(uri,
157156 """
158157 directory = directory or tempfile .mkdtemp ()
159158 filename = os .path .basename (uri )
160- crate_dir = re .sub ('\.tar(\.gz)?$' , '' , filename )
159+ crate_dir = re .sub (r '\.tar(\.gz)?$' , '' , filename )
161160 crate_home = os .path .join (directory , crate_dir )
162161
163162 if os .path .exists (crate_home ):
@@ -224,6 +223,7 @@ def __init__(self,
224223 self .env = env or {}
225224 self .env .setdefault ('CRATE_USE_IPV4' , 'true' )
226225 self ._stdout_consumers = []
226+ self .conn_pool = urllib3 .PoolManager (num_pools = 1 )
227227
228228 crate_home = os .path .abspath (crate_home )
229229 if crate_exec is None :
@@ -319,7 +319,10 @@ def start(self):
319319 def stop (self ):
320320 if self .process :
321321 self .process .terminate ()
322- self .process = None
322+ self .process .communicate (timeout = 10 )
323+ self .process .stdout .close ()
324+ self .process = None
325+ self .conn_pool .clear ()
323326 self .monitor .stop ()
324327 self ._clean ()
325328
0 commit comments