)]}'
{"oslo_messaging/_drivers/pool.py":[{"author":{"_account_id":8770,"name":"Ken Giusti","email":"kgiusti@gmail.com","username":"kgiusti"},"change_message_id":"3a2d180eb9b3b3bc868a3803f9af9b1b0e82cd00","unresolved":false,"context_lines":[{"line_number":56,"context_line":"        self._cond \u003d threading.Condition()"},{"line_number":57,"context_line":"        self._items \u003d collections.deque()"},{"line_number":58,"context_line":""},{"line_number":59,"context_line":"    def expire(self):"},{"line_number":60,"context_line":"        now \u003d time.time()"},{"line_number":61,"context_line":"        while len(self._items) \u003e self._min_size:"},{"line_number":62,"context_line":"            push_time, item \u003d self._items.popleft()"}],"source_content_type":"text/x-python","patch_set":3,"id":"1aa78d24_8c19b5d3","line":59,"updated":"2016-07-13 13:41:57.000000000","message":"If I understand correctly - this method expects the _cond to be held while it is called.  If that\u0027s correct maybe this method should be private (e.g. _expire)?","commit_id":"7f0c7844813515f9667f005ccadffa80ef18112f"},{"author":{"_account_id":1297,"name":"Joshua Harlow","email":"jxharlow@godaddy.com","username":"harlowja"},"change_message_id":"02bde2347fdc5617c5147b760da5746ba3d9bb3c","unresolved":false,"context_lines":[{"line_number":72,"context_line":"    def put(self, item):"},{"line_number":73,"context_line":"        \"\"\"Return an item to the pool.\"\"\""},{"line_number":74,"context_line":"        with self._cond:"},{"line_number":75,"context_line":"            self._items.append((time.time(), item))"},{"line_number":76,"context_line":"            self._cond.notify()"},{"line_number":77,"context_line":""},{"line_number":78,"context_line":"    def get(self):"}],"source_content_type":"text/x-python","patch_set":5,"id":"1aa78d24_40ea9775","line":75,"updated":"2016-07-15 00:37:03.000000000","message":"IMHO use the following instead of recreating it:\n\n    \u003e\u003e\u003e from oslo_utils import timeutils\n    \u003e\u003e\u003e a \u003d timeutils.StopWatch(duration\u003d5)\n    \u003e\u003e\u003e a.expired()\n    \u003e\u003e\u003e a.start()\n    \u003coslo_utils.timeutils.StopWatch object at 0x102188910\u003e\n    \u003e\u003e\u003e a.expired()\n    False\n    \u003e\u003e\u003e a.expired()\n    False\n    \u003e\u003e\u003e a.expired()\n    False\n    \u003e\u003e\u003e a.expired()\n    False\n    \u003e\u003e\u003e a.expired()\n    False\n    \u003e\u003e\u003e a.expired()\n    True\n\nThen later in the _expire method u can do a little bit less since the expiry method of the stop watches will already do what u want (and do it in a way that other projects are already using).","commit_id":"77b16be26475543bb069d012a495902e9b9dd6b8"},{"author":{"_account_id":19520,"name":"Kirill Bespalov","email":"kbespalov@mirantis.com","username":"k.bespalov"},"change_message_id":"042e869a063ff6bf45e898c598622cb6d70e415b","unresolved":false,"context_lines":[{"line_number":72,"context_line":"    def put(self, item):"},{"line_number":73,"context_line":"        \"\"\"Return an item to the pool.\"\"\""},{"line_number":74,"context_line":"        with self._cond:"},{"line_number":75,"context_line":"            self._items.append((time.time(), item))"},{"line_number":76,"context_line":"            self._cond.notify()"},{"line_number":77,"context_line":""},{"line_number":78,"context_line":"    def get(self):"}],"source_content_type":"text/x-python","patch_set":5,"id":"1aa78d24_ad5a3df0","line":75,"in_reply_to":"1aa78d24_40ea9775","updated":"2016-07-15 11:19:00.000000000","message":"Done","commit_id":"77b16be26475543bb069d012a495902e9b9dd6b8"},{"author":{"_account_id":1297,"name":"Joshua Harlow","email":"jxharlow@godaddy.com","username":"harlowja"},"change_message_id":"0c37578ecfbad30126b3c116f07a0d7ef52ea8ea","unresolved":false,"context_lines":[{"line_number":108,"context_line":"        with self._cond:"},{"line_number":109,"context_line":"            while True:"},{"line_number":110,"context_line":"                try:"},{"line_number":111,"context_line":"                    _, item \u003d self._items.pop()"},{"line_number":112,"context_line":"                    yield item"},{"line_number":113,"context_line":"                except IndexError:"},{"line_number":114,"context_line":"                    break"}],"source_content_type":"text/x-python","patch_set":5,"id":"1aa78d24_20178b55","line":111,"updated":"2016-07-15 00:39:28.000000000","message":"Also why the change to pop from popleft?","commit_id":"77b16be26475543bb069d012a495902e9b9dd6b8"},{"author":{"_account_id":19520,"name":"Kirill Bespalov","email":"kbespalov@mirantis.com","username":"k.bespalov"},"change_message_id":"042e869a063ff6bf45e898c598622cb6d70e415b","unresolved":false,"context_lines":[{"line_number":108,"context_line":"        with self._cond:"},{"line_number":109,"context_line":"            while True:"},{"line_number":110,"context_line":"                try:"},{"line_number":111,"context_line":"                    _, item \u003d self._items.pop()"},{"line_number":112,"context_line":"                    yield item"},{"line_number":113,"context_line":"                except IndexError:"},{"line_number":114,"context_line":"                    break"}],"source_content_type":"text/x-python","patch_set":5,"id":"1aa78d24_1498c369","line":111,"in_reply_to":"1aa78d24_20178b55","updated":"2016-07-15 11:19:00.000000000","message":"It\u0027s because I want to pop items starting with last recently used to oldest items, to kept old items in the tail of queue then iteration is stop. It affects on expire() method.","commit_id":"77b16be26475543bb069d012a495902e9b9dd6b8"},{"author":{"_account_id":1297,"name":"Joshua Harlow","email":"jxharlow@godaddy.com","username":"harlowja"},"change_message_id":"0c37578ecfbad30126b3c116f07a0d7ef52ea8ea","unresolved":false,"context_lines":[{"line_number":109,"context_line":"            while True:"},{"line_number":110,"context_line":"                try:"},{"line_number":111,"context_line":"                    _, item \u003d self._items.pop()"},{"line_number":112,"context_line":"                    yield item"},{"line_number":113,"context_line":"                except IndexError:"},{"line_number":114,"context_line":"                    break"},{"line_number":115,"context_line":""}],"source_content_type":"text/x-python","patch_set":5,"id":"1aa78d24_a0241bc6","line":112,"updated":"2016-07-15 00:39:28.000000000","message":"Hmmm, holding a lock while yielding, eck. Dangerous area here... (especially if the caller never closes the iterator).","commit_id":"77b16be26475543bb069d012a495902e9b9dd6b8"},{"author":{"_account_id":19520,"name":"Kirill Bespalov","email":"kbespalov@mirantis.com","username":"k.bespalov"},"change_message_id":"042e869a063ff6bf45e898c598622cb6d70e415b","unresolved":false,"context_lines":[{"line_number":109,"context_line":"            while True:"},{"line_number":110,"context_line":"                try:"},{"line_number":111,"context_line":"                    _, item \u003d self._items.pop()"},{"line_number":112,"context_line":"                    yield item"},{"line_number":113,"context_line":"                except IndexError:"},{"line_number":114,"context_line":"                    break"},{"line_number":115,"context_line":""}],"source_content_type":"text/x-python","patch_set":5,"id":"1aa78d24_6d6055a5","line":112,"in_reply_to":"1aa78d24_a0241bc6","updated":"2016-07-15 11:19:00.000000000","message":"yes, here is a problem, but we use iteration over pool only in order to close all connections then AMQPDriver is stopping  \n\nI remove \u0027with self._cond\u0027 statement and wrap in try\u0026except extracting items in the expire() method to prevent race condition.","commit_id":"77b16be26475543bb069d012a495902e9b9dd6b8"},{"author":{"_account_id":1297,"name":"Joshua Harlow","email":"jxharlow@godaddy.com","username":"harlowja"},"change_message_id":"dc59fa975f55c1eb42286bc47cdd75ae855867ff","unresolved":false,"context_lines":[{"line_number":64,"context_line":"                    if ttl_watch.expired():"},{"line_number":65,"context_line":"                        item.close()"},{"line_number":66,"context_line":"                        self._current_size -\u003d 1"},{"line_number":67,"context_line":"                        LOG.debug(\"Idle connection is expired and closed.\""},{"line_number":68,"context_line":"                                  \" Pool size: %d\" % len(self._items))"},{"line_number":69,"context_line":"                    else:"},{"line_number":70,"context_line":"                        self._items.appendleft((ttl_watch, item))"}],"source_content_type":"text/x-python","patch_set":6,"id":"fad55976_c902513e","line":67,"updated":"2016-07-15 22:57:53.000000000","message":"So other idea here is that this log statement doesn\u0027t really make sense since this is in the Pool class not in the connection pool class.\n\nWhat I recommend is to do something like the following,\n\n\n    def __init__(self, max_size\u003d4, min_size\u003d2, ttl\u003d1200,\n                 close_func\u003dNone):\n        super(Pool, self).__init__()\n        self._min_size \u003d min_size\n        self._max_size \u003d max_size\n        self._current_size \u003d 0\n        self._cond \u003d threading.Condition()\n        self._item_ttl \u003d ttl\n        self._close_func \u003d close_func\n        self._items \u003d collections.deque()\n\nThen use `close_func` if provided to close the item that u are expiring, in the pool connection class this would use the following mini-function to do the closing.\n\n   def _close_conn(conn):\n     conn.close()\n     LOG.debug(\"Idle connection %s has expired and been closed.\", conn)","commit_id":"cc9d4d369109286151647dd980718014eae91214"},{"author":{"_account_id":9459,"name":".Haifeng Yan","email":"yanheven@qq.com","username":"yan"},"change_message_id":"040c06e185c449fae583aef0c1d2025a41256010","unresolved":false,"context_lines":[{"line_number":67,"context_line":"                        self._current_size -\u003d 1"},{"line_number":68,"context_line":"                    else:"},{"line_number":69,"context_line":"                        self._items.appendleft((ttl_watch, item))"},{"line_number":70,"context_line":"                        break"},{"line_number":71,"context_line":"                except IndexError:"},{"line_number":72,"context_line":"                    break"},{"line_number":73,"context_line":""}],"source_content_type":"text/x-python","patch_set":9,"id":"dada55a8_0f9ce55b","line":70,"range":{"start_line":70,"start_character":24,"end_line":70,"end_character":29},"updated":"2016-07-21 06:21:40.000000000","message":"how about adding comments in class docstring to explain the left item of pool is always the oldest.otherwise hard to understand why break here.","commit_id":"f17ed599859788485b6e72d93a17443badffaddf"},{"author":{"_account_id":9459,"name":".Haifeng Yan","email":"yanheven@qq.com","username":"yan"},"change_message_id":"040c06e185c449fae583aef0c1d2025a41256010","unresolved":false,"context_lines":[{"line_number":109,"context_line":""},{"line_number":110,"context_line":"    def iter_free(self):"},{"line_number":111,"context_line":"        \"\"\"Iterate over free items.\"\"\""},{"line_number":112,"context_line":"        while 1:"},{"line_number":113,"context_line":"            try:"},{"line_number":114,"context_line":"                _, item \u003d self._items.pop()"},{"line_number":115,"context_line":"                yield item"}],"source_content_type":"text/x-python","patch_set":9,"id":"dada55a8_c995ad33","line":112,"range":{"start_line":112,"start_character":14,"end_line":112,"end_character":15},"updated":"2016-07-21 06:21:40.000000000","message":"while True","commit_id":"f17ed599859788485b6e72d93a17443badffaddf"}]}
