2016-06-14 53 views
1

我在從Python代碼調用/觸發Luigi任務時遇到問題。錯誤:luigi中的未捕獲異常(TypeError:必須是字符串或緩衝區,而不是無)

  • 基本上我需要一個觸發任務路易吉就像我們做的命令行,但是從Python代碼
  • 我使用supbrocess.popen使用shell命令
  • 我打電話給一個路易吉任務有命名爲test.py一個測試代碼和在模塊 task_scheduler.py測試類,其中包含我的路易任務(在相同的位置/ DIR兩個模塊)

 import luigi 
 
     class TestClass(luigi.Task): 
 
      # param = luigi.DictParameter(default=dict()) 
 

 
      def requires(self): 
 
       print "I am TestClass req" 
 

 
      def run(self): 
 
       with open('myfile.txt', 'w') as f: 
 
        f.write("asasasas") 
 

 
       print "I am TestClass run"

import subprocess 
 

 
p = subprocess.Popen("python -m luigi --module task_scheduler TestClass", shell=True, stdout=subprocess.PIPE, stderr=subprocess.PIPE) 
 

 
print p.pid 
 
(output, err) = p.communicate() 
 

 
print "-------------O/P-------------" 
 
print output 
 
print "-------------error-------------" 
 
print err

但我得到什麼我做錯了這裏的誤差

52688 
 
-------------O/P------------- 
 

 
-------------error------------- 
 
ERROR: Uncaught exception in luigi 
 
Traceback (most recent call last): 
 
    File "/Library/Python/2.7/site-packages/luigi/retcodes.py", line 61, in run_with_retcodes 
 
    worker = luigi.interface._run(argv)['worker'] 
 
    File "/Library/Python/2.7/site-packages/luigi/interface.py", line 238, in _run 
 
    return _schedule_and_run([cp.get_task_obj()], worker_scheduler_factory) 
 
    File "/Library/Python/2.7/site-packages/luigi/interface.py", line 172, in _schedule_and_run 
 
    not(lock.acquire_for(env_params.lock_pid_dir, env_params.lock_size, kill_signal))): 
 
    File "/Library/Python/2.7/site-packages/luigi/lock.py", line 82, in acquire_for 
 
    my_pid, my_cmd, pid_file = get_info(pid_dir) 
 
    File "/Library/Python/2.7/site-packages/luigi/lock.py", line 67, in get_info 
 
    pid_file = os.path.join(pid_dir, hashlib.md5(cmd_hash).hexdigest()) + '.pid' 
 
TypeError: must be string or buffer, not None

任何人都可以請建議我嗎? 如果我使用shell提示,命令「python -m luigi --module task_scheduler TestClass」完美工作

回答

2

我剛剛嘗試從命令行執行test.py。 看來,當我使用IDE運行(PyCharm),然後只有它給這個問題

+0

你能以某種方式解決PyCharm的這個問題嗎?我有同樣的問題:( – Matthias

1

這是固定的版本2.2.0。檢查github問題#1654

相關問題