在烧瓶内使用包装运行壳

时间:2018-07-16 13:55:13

标签: python flask

我正在尝试创建一个使用Pyomo运行优化模型的小型应用程序。它通常会编写一个文本文件并使用shell命令运行它。在webapp外部,它可以正常工作,但是当我尝试在flask中运行时,出现以下错误跟踪:

Optimizing Line Assignment...
[2018-07-16 09:26:06,968] ERROR in app: Exception on /uploader [POST]
Traceback (most recent call last):
  File "C:\Users\bbrunaud\AppData\Roaming\Python\Python36\site-packages\flask\app.py", line 2292, in wsgi_app
    response = self.full_dispatch_request()
  File "C:\Users\bbrunaud\AppData\Roaming\Python\Python36\site-packages\flask\app.py", line 1815, in full_dispatch_request
    rv = self.handle_user_exception(e)
  File "C:\Users\bbrunaud\AppData\Roaming\Python\Python36\site-packages\flask\app.py", line 1718, in handle_user_exception
    reraise(exc_type, exc_value, tb)
  File "C:\Users\bbrunaud\AppData\Roaming\Python\Python36\site-packages\flask\_compat.py", line 35, in reraise
    raise value
  File "C:\Users\bbrunaud\AppData\Roaming\Python\Python36\site-packages\flask\app.py", line 1813, in full_dispatch_request
    rv = self.dispatch_request()
  File "C:\Users\bbrunaud\AppData\Roaming\Python\Python36\site-packages\flask\app.py", line 1799, in dispatch_request
    return self.view_functions[rule.endpoint](**req.view_args)
  File "H:\Python\Flask_app\flaskapp.py", line 44, in uploader
    optimize_line_assignment(m)
  File "H:\Python\optim\optim\line_assignment.py", line 90, in optimize_line_assignment
    mip.solve(m)
  File "C:\Users\bbrunaud\AppData\Roaming\Python\Python36\site-packages\pyomo\opt\base\solvers.py", line 608, in solve
    _status = self._apply_solver()
  File "C:\Users\bbrunaud\AppData\Roaming\Python\Python36\site-packages\pyomo\opt\solver\shellcmd.py", line 242, in _apply_solver
    self._rc, self._log = self._execute_command(self._command)
  File "C:\Users\bbrunaud\AppData\Roaming\Python\Python36\site-packages\pyomo\opt\solver\shellcmd.py", line 305, in _execute_command
    tee   = self._tee
  File "C:\Users\bbrunaud\AppData\Roaming\Python\Python36\site-packages\pyutilib\subprocess\processmngr.py", line 544, in run_command
    = signal.signal(signal.SIGINT, handler)
  File "c:\program files\python36\lib\signal.py", line 47, in signal
    handler = _signal.signal(_enum_to_int(signalnum), _enum_to_int(handler))
ValueError: signal only works in main thread

运行Flask服务器时,我关闭了调试模式,但是仍然出现错误。有什么建议吗?

谢谢!

0 个答案:

没有答案