我是创建网络的新手,对python也是比较陌生的。我最近买了第二台电脑来运行一些python程序。第二台计算机将数据输入我的主计算机上的mysql数据库。
我收到了很多10055个错误。有时来自selenium/urllib,有时来自尝试连接到mysql数据库。这些错误可以提供:
硒- Errno 10055。无法在套接字上执行操作,因为系统缓冲区空间不足或队列已满
MySQL -无法连接到IP上的MySQL服务器(10055)
我已经寻找了几个小时来解决这个问题,但没有找到一个有效的解决方案。有什么想法吗?
我运行的是windows7,运行在一台功能相当强大的电脑上。我真的怀疑这是一个记忆问题。
导致问题的一段代码如下(我得到的是can't connect to mysql server) -它只是有时会给出问题:
def connect_to_database(schema_name):
import MySQLdb
import socket
counter = 0
#try 100 times until a connection is made
while counter <= 100:
try:
#gets ip of host comp
ip = socket.gethostbyname('PC NAME')
conn = MySQLdb.connect(ip, "username", "pw", schema_name)
c = conn.cursor()
conn.set_character_set('utf8')
c.execute('SET NAMES utf8;')
c.execute('SET CHARACTER SET utf8;')
c.execute('SET character_set_connection=utf8;')
break
except Exception, err:
print traceback.format_exc()
try:
#if failure, use different ip, so far i have only seen 2 ip's for the network.
if socket.gethostbyname(socket.gethostname()) == '10.0.0.13':
ip = '10.0.0.14'
else:
ip = '10.0.0.13'
conn = MySQLdb.connect(ip, "username", "pw", schema_name)
c = conn.cursor()
conn.set_character_set('utf8')
c.execute('SET NAMES utf8;')
c.execute('SET CHARACTER SET utf8;')
c.execute('SET character_set_connection=utf8;')
break
except Exception, err:
print traceback.format_exc()
counter = counter + 1
return c, conn发布于 2013-03-01 09:27:16
我想我有一个解决方案。更多的测试将得到证实。我将我的windows7机器上的主机端口数量增加到65,000个。有关说明,请参阅以下内容。
https://stackoverflow.com/questions/15144846
复制相似问题