我正在運行一個調用子進程的python腳本。它超時,然後立即看到子過程(在這種情況下是BCP調用)完成。事實上,我可以看到它在數據庫中完整。另外,我可以直接在命令行上運行BCP命令,它工作得很好。從python調用BCP會引發超時異常,然後立即完成
這裏是我的python腳本吐出到命令提示符:
C:\FaceIAPS\StudyDataFiles> py .\RUN_DATA.py
Synchronizing 80 subjects
Subject 11
Starting copy...
Traceback (most recent call last):
File ".\RUN_DATA.py", line 261, in <module>
bulk_import(upload_file, 'Facet_Data')
File ".\RUN_DATA.py", line 171, in bulk_import
subprocess.check_call("bcp BehaviorResearch.." + table_to_upload_to + " in " + filename_to_be_uploaded + " -T -c -S
PBB-C202B-2\BEHAVIORRESEARCH -e bulk_copy_errors.log", shell=True, timeout=5)
File "C:\Python34\lib\subprocess.py", line 554, in check_call
retcode = call(*popenargs, **kwargs)
File "C:\Python34\lib\subprocess.py", line 537, in call
return p.wait(timeout=timeout)
File "C:\Python34\lib\subprocess.py", line 1157, in wait
raise TimeoutExpired(self.args, timeout)
subprocess.TimeoutExpired: Command 'bcp BehaviorResearch..Facet_Data in _temp_ -T -c -S PBB-C202B-2\BEHAVIORRESEARCH -e
bulk_copy_errors.log' timed out after 5 seconds
1000 rows sent to SQL Server. Total sent: 1000
1000 rows sent to SQL Server. Total sent: 2000
PS C:\FaceIAPS\StudyDataFiles> 1000 rows sent to SQL Server. Total sent: 3000
1000 rows sent to SQL Server. Total sent: 4000
1000 rows sent to SQL Server. Total sent: 5000
1000 rows sent to SQL Server. Total sent: 6000
1000 rows sent to SQL Server. Total sent: 7000
1000 rows sent to SQL Server. Total sent: 8000
1000 rows sent to SQL Server. Total sent: 9000
1000 rows sent to SQL Server. Total sent: 10000
1000 rows sent to SQL Server. Total sent: 11000
1000 rows sent to SQL Server. Total sent: 12000
1000 rows sent to SQL Server. Total sent: 13000
1000 rows sent to SQL Server. Total sent: 14000
1000 rows sent to SQL Server. Total sent: 15000
1000 rows sent to SQL Server. Total sent: 16000
16102 rows copied.
Network packet size (bytes): 4096
Clock Time (ms.) Total : 5164 Average : (3118.13 rows per sec.)
正如你所看到的,在命令提示符下已經分裂與BCP調用的輸出。
怎麼回事,我該如何解決?
編輯:我如何固定它
更改子呼籲:「在」
arguments = ["bcp", "BehaviorResearch.." + table_to_upload_to, "in", filename_to_be_uploaded, "-T", "-c", "-S PBB-C202B-2\BEHAVIORRESEARCH", "-e bulk_copy_errors.log"]
subprocess.call(arguments, timeout=30)
作爲一個供參考的門外漢,是它自己的說法。
你問的是什麼問題? – AHuman