OperationalError:(2001,“无法创建UNIX套接字(24)”)

时间:2012-02-15 11:33:08

标签: python mysql django sockets exception

我使用的是django-1.2和python-2.6,我使用的是mysql服务器。

工作一段时间后 - 选择和更新记录,我收到了这个错误:

Exception in thread Thread-269:
Traceback (most recent call last):
  File "/usr/lib64/python2.6/threading.py", line 532, in __bootstrap_inner
  File "dispatcher.py", line 42, in run
  File "/usr/lib/python2.6/site-packages/django/db/models/query.py", line 80, in __len__  
  File "/usr/lib/python2.6/site-packages/django/db/models/query.py", line 271, in iterator  
  File "/usr/lib/python2.6/site-packages/django/db/models/sql/compiler.py", line 677, in results_iter  
  File "/usr/lib/python2.6/site-packages/django/db/models/sql/compiler.py", line 731, in execute_sql  
  File "/usr/lib/python2.6/site-packages/django/db/backends/__init__.py", line 75, in cursor  
  File "/usr/lib/python2.6/site-packages/django/db/backends/mysql/base.py", line 297, in _cursor  
  File "/usr/lib64/python2.6/site-packages/MySQLdb/__init__.py", line 81, in Connect  
  File "/usr/lib64/python2.6/site-packages/MySQLdb/connections.py", line 187, in __init__  
OperationalError: (2001, "Can't create UNIX socket (24)")

这是我dispatcher.py的第41,42行:

dataList = Mydata.objects.filter(date__isnull=True)[:chunkSize]
print '%s - DB worker finished reading %s entrys' % (datetime.now(),len(dataList))

为什么我收到此错误的任何线索?
我试过谷歌搜索但找不到答案。

我使用django连接到数据库 - (我正在使用localhost)

2 个答案:

答案 0 :(得分:1)

在我的机器上,errno == 24被定义为

#define EMFILE          24      /* Too many open files */

这意味着你的文件描述符已经用完了。你的应用程序通过一次又一次地打开它们(而不是关闭它们)来“泄漏”文件描述符。

答案 1 :(得分:0)

也许你不会忘记关闭档案。但是同时打开了太多文件。