Python GLib错误**:无法创建管道主回路唤醒:打开的文件太多
我正在使用python的多处理库并行运行两个函数。代码从文件中读取数据,将数据插入数据库,并将任何错误记录到错误文件中。此程序正在无限期运行。在第一个循环之后,我遇到了一个错误:Python GLib错误**:无法创建管道主回路唤醒:打开的文件太多,python,Python,我正在使用python的多处理库并行运行两个函数。代码从文件中读取数据,将数据插入数据库,并将任何错误记录到错误文件中。此程序正在无限期运行。在第一个循环之后,我遇到了一个错误:GLib error**:无法创建管道主回路唤醒:打开的文件太多。我不确定这是从哪里来的,因为我确保在使用后打开和关闭文件。下面我有一些示例代码 class DataProcessing: def __init___(configlog,sleeptime,logfile):
GLib error**:无法创建管道主回路唤醒:打开的文件太多
。我不确定这是从哪里来的,因为我确保在使用后打开和关闭文件。下面我有一些示例代码
class DataProcessing:
def __init___(configlog,sleeptime,logfile):
self.configlog = configlog
self.sleeptime = sleeptime
self.logfile = logfile
self.manageClient()
self.setupDB()
def manageClient(self):
s=subprocess.Popen([run streaming software])
time.sleep(self.sleeptime)
s.kill()
del s
self.stream = []
with open(self.logfile) as f:
for line in f.readLines():
if "Data" in line:
self.stream.append(line)
def setupDB(self):
""""Set up connection to database using MySQLdb library"""
def pushData(self):
errorfile = open("errorlog.log","a")
for line in self.stream:
"""Check of for existing stream in DB. Update record in DB"""
try:
cur.execute(sql_query)
db.commit()
except MySQLdb, e:
errorfile.write(e + "\n")
db.rollback()
errorfile.close()
cur.close()
db.close()
def firstProcess():
while True:
initialProcess = DataProcessing("configlog",300,"logfile.log")
initialProcess.pushData()
def secondProcess():
while True:
finalProcess = DataProcessing("otherlog",86000,"otherlog.log")
finalProcess.pushData()
p1 = Process(target = firstProcess)
p1.start()
p2 = Process(target = secondProcess)
p2.start()
打印消息的不是Python,而是与GLib相关的东西。你需要展示一个完整的例子来重现这个问题。@RossRidge我想我没有比这个更具体的了。虽然我意识到流媒体软件大幅增加了打开文件描述符的数量,超过了硬限制,这似乎是我出现错误的原因。打印消息的不是Python,而是与GLib有关的东西。你需要展示一个完整的例子来重现这个问题。@RossRidge我想我没有比这个更具体的了。虽然我意识到流媒体软件大幅增加了打开的文件描述符的数量,超过了硬限制,这似乎就是为什么我会出现这个错误。