gevent连接池代码: https://github.com/gevent/gevent/blob/master/examples/psycopg2_pool.py
自己用的: https://gist.github.com/pikeszfish/83c24e34c3ccaec4c4a8
通过import了这个pool
但有的时候会遇到这样的出错
Traceback (most recent call last):
File "/usr/local/lib/python2.7/dist-packages/django/core/handlers/base.py", line 115, in get_response
response = callback(request, callback_args, *callback_kwargs)
File "path/to/project/web/helper.py", line 151, in _decorator
return func(request, args, *kwargs)
File "/usr/local/lib/python2.7/dist-packages/django/views/decorators/csrf.py", line 77, in wrapped_view
return view_func(args, *kwargs)
File "path/to/project/web/api.py", line 611, in download_trackpoints
former_result = get_trackpoints(workout.id)
File "path/to/project/web/helper.py", line 1616, in get_trackpoints
result = pool.fetchone(final_sql)
File "path/to/project/web/singleton.py", line 138, in fetchone
with self.cursor(**kwargs) as cursor:
File "/usr/lib/python2.7/contextlib.py", line 17, in enter
return self.gen.next()
File "path/to/project/web/singleton.py", line 121, in cursor
with self.connection(isolation_level) as conn:
File "/usr/lib/python2.7/contextlib.py", line 17, in enter
return self.gen.next()
File "path/to/project/web/singleton.py", line 93, in connection
conn = self.get_one()
File "path/to/project/web/singleton.py", line 70, in get_one
return pool.get()
File "/usr/local/lib/python2.7/dist-packages/gevent/queue.py", line 200, in get
result = waiter.get()
File "/usr/local/lib/python2.7/dist-packages/gevent/hub.py", line 575, in get
return self.hub.switch()
File "/usr/local/lib/python2.7/dist-packages/gevent/hub.py", line 338, in switch
return greenlet.switch(self)
LoopExit: This operation would block forever
查看RDS,有时候出现特别高的日志盘的IOPS出现。
内存有时候出现 PG RDS 的相关进程占用的内存超过实例规格。
在postgres中主要使用了一些GIS的数据和函数