prom icon indicating copy to clipboard operation
prom copied to clipboard

Prom async bug

Open Jaymon opened this issue 9 years ago • 1 comments

On one of our tests, the foo/bar script uses greenthreads, and when they both start up without a wait between them they will cause a connection pool error

c1 = ScriptClient("foo/bar")
r1 = c1.run_async()

c2 = ScriptClient("foo/bar")
r2 = c2.run_async()

c1.wait()
c2.wait()

The error:

'NoneType' object has no attribute 'getconn'
Traceback (most recent call last):
  ...
  File "/usr/local/lib/python2.7/dist-packages/prom/query.py", line 573, in get_one
    d = self._query('get_one')
  File "/usr/local/lib/python2.7/dist-packages/prom/query.py", line 682, in _query
    return getattr(i, method_name)(s, self) # i.method_name(schema, query)
  File "/usr/local/lib/python2.7/dist-packages/prom/interface/base.py", line 485, in get_one
    ret = self._get_query(self._get_one, schema, query, **kwargs)
  File "/usr/local/lib/python2.7/dist-packages/prom/decorators.py", line 58, in wrapper
    return func(self, *args, **kwargs)
  File "/usr/local/lib/python2.7/dist-packages/prom/interface/base.py", line 453, in _get_query
    with self.connection(**kwargs) as connection:
  File "/usr/lib/python2.7/contextlib.py", line 17, in __enter__
    return self.gen.next()
  File "/usr/local/lib/python2.7/dist-packages/prom/interface/base.py", line 177, in connection
    self.raise_error(e)
  File "/usr/local/lib/python2.7/dist-packages/prom/interface/base.py", line 167, in connection
    connection = self.get_connection()
  File "/usr/local/lib/python2.7/dist-packages/prom/interface/postgres.py", line 98, in get_connection
    connection = self.connection_pool.getconn()
AttributeError: 'NoneType' object has no attribute 'getconn'

This only shows up in tests, I think the reason why is because we've cleared all the tables and so the prom error handling table creation code kicks on the first connection and then the second connection causes a problem?

Jaymon avatar May 23 '15 00:05 Jaymon