python打开另一个程序_python 新手问题啊,为什么我运行一个python程序,另一个就会自动退出呢?始终只能运行一个...
/data/python/caiji_asc.py
/data/python/caiji_desc.py
兩個文件的代碼幾乎一樣的,就是查詢mysql的時候order 排序不一樣
下面是具體代碼,剛學幾天,網上東拼西湊出來的,高手幫忙看看吧
我用ssh連接服務器 運行這兩個python 程序始終都是一個運行了另一個自動exit。。實在不明白怎么回事??
#!/usr/bin/python
#-*-coding:utf-8-*-
import MySQLdb, os, socket, time;
import MySQLdb.cursors;
import urllib
User = 'root';
Passwd = '123456';
Host = 'localhost';
Db = 'test_xs';
conn = MySQLdb.connect(user=User,passwd=Passwd,host=Host,db=Db);
mysql = conn.cursor(cursorclass = MySQLdb.cursors.DictCursor);
mysql.execute("select * from image order by id asc");
result = mysql.fetchall();
startTime = time.time();
timeout = 10; # in seconds
socket.setdefaulttimeout(timeout);
for row in result:
dir = os.path.dirname(row['path']);
if not os.path.exists(dir):
os.makedirs(dir);
os.chmod(dir, 0777);
os.chmod(os.path.dirname(dir), 0777);
data = urllib.urlretrieve(row['url'], row['path']);
os.chmod(row['path'], 0777);
mysql.execute("delete from image where id = %s", row['id']);
passTime = int(time.time()) - int(startTime);
if passTime >= 3600:
break;
print str(row['id']);
mysql.close();
conn.close();
[root@localhost ~]# nohup /data/python/caiji_asc.py > /dev/null 2>&1 &
[1] 4272
[root@localhost ~]# nohup /data/python/caiji_desc.py > /dev/null 2>&1 &
[2] 4273
[1] Exit 126 nohup /data/python/caiji_asc.py > /dev/null 2>&1
[root@localhost ~]# nohup /data/python/caiji_asc.py > /dev/null 2>&1 &
[3] 4274
[2] Exit 126 nohup /data/python/caiji_desc.py > /dev/null 2>&1
[root@localhost ~]# nohup python /data/python/caiji_asc.py > /dev/null 2>&1 &
[4] 4275
[3] Exit 126 nohup /data/python/caiji_asc.py > /dev/null 2>&1
[root@localhost ~]# nohup /data/python/caiji_asc.py > /dev/null 2>&1 &
[5] 4277
[root@localhost ~]# nohup /data/python/caiji_desc.py > /dev/null 2>&1 &
[6] 4278
[5] Exit 126 nohup /data/python/caiji_asc.py > /dev/null 2>&1
[root@localhost ~]# /data/python/caiji_desc.py > /dev/null 2>&1 &
[7] 4283
[4] Done nohup python /data/python/caiji_asc.py > /dev/null 2>&1
[6] Exit 126 nohup /data/python/caiji_desc.py > /dev/null 2>&1
[root@localhost ~]# /data/python/caiji_asc.py > /dev/null 2>&1 &
[8] 4284
[7] Exit 126 /data/python/caiji_desc.py > /dev/null 2>&1
貌似數據庫里面數據已經都被刪除了的問題吧 。。 現在測試又正常了。 暈死。。
總結
以上是生活随笔為你收集整理的python打开另一个程序_python 新手问题啊,为什么我运行一个python程序,另一个就会自动退出呢?始终只能运行一个...的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 贫困户如何贷款
- 下一篇: python高级语言应用报告_高级语言程