日韩av黄I国产麻豆传媒I国产91av视频在线观看I日韩一区二区三区在线看I美女国产在线I麻豆视频国产在线观看I成人黄色短片

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 >

python打开另一个程序_python 新手问题啊,为什么我运行一个python程序,另一个就会自动退出呢?始终只能运行一个...

發布時間:2024/9/27 43 豆豆
生活随笔 收集整理的這篇文章主要介紹了 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程序,另一个就会自动退出呢?始终只能运行一个...的全部內容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。