connection.commit抛出磁盘I / O错误,但*仅*通过procmail运行脚本时

时间:2015-09-29 07:30:23

标签: django procmail

我有一个Django python脚本,应该在收到电子邮件时运行。电子邮件将发送到procmail。用户目录中的LOGFILE=debug.log :0 * !^FROM_DAEMON * !^FROM_MAILER * !^X-[-\w]+Loop: .* | sudo /path/to/project/process_message.sh 文件如下所示:

DIR=$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )
CONTENTS=$(cat)

cd $DIR
source ./bin/activate
echo -e "$CONTENTS" | ./project/manage.py command_name

process_message.sh脚本如下所示:

Traceback (most recent call last):
  File "./app/manage.py", line 10, in <module>
    execute_from_command_line(sys.argv)
  File "/path/to/project/local/lib/python3.4/dist-packages/django/core/management/__init__.py", line 338, in execute_from_command_line
    utility.execute()
  File "/path/to/project/local/lib/python3.4/dist-packages/django/core/management/__init__.py", line 330, in execute
    self.fetch_command(subcommand).run_from_argv(self.argv)
  File "/path/to/project/local/lib/python3.4/dist-packages/django/core/management/base.py", line 393, in run_from_argv
    self.execute(*args, **cmd_options)
  File "/path/to/project/local/lib/python3.4/dist-packages/django/core/management/base.py", line 444, in execute
    output = self.handle(*args, **options)
  File "/path/to/project/app/communication/management/commands/process_reply.py", line 133, in handle
    self.process_email(email_obj)
  File "/path/to/project/app/communication/models.py", line 37, in from_email_addr
    return self.from_code(code)
  File "/path/to/project/app/communication/models.py", line 41, in from_code
    match = self.get(...)
  File "/path/to/project/local/lib/python3.4/dist-packages/django/db/models/manager.py", line 127, in manager_method
    return getattr(self.get_queryset(), name)(*args, **kwargs)
  File "/path/to/project/local/lib/python3.4/dist-packages/django/db/models/query.py", line 328, in get
    num = len(clone)
  File "/path/to/project/local/lib/python3.4/dist-packages/django/db/models/query.py", line 144, in __len__
    self._fetch_all()
  File "/path/to/project/local/lib/python3.4/dist-packages/django/db/models/query.py", line 965, in _fetch_all
    self._result_cache = list(self.iterator())
  File "/path/to/project/local/lib/python3.4/dist-packages/django/db/models/query.py", line 238, in iterator
    results = compiler.execute_sql()
  File "/path/to/project/local/lib/python3.4/dist-packages/django/db/models/sql/compiler.py", line 840, in execute_sql
    cursor.execute(sql, params)
  File "/path/to/project/local/lib/python3.4/dist-packages/django/db/backends/utils.py", line 79, in execute
    return super(CursorDebugWrapper, self).execute(sql, params)
  File "/path/to/project/local/lib/python3.4/dist-packages/django/db/backends/utils.py", line 64, in execute
    return self.cursor.execute(sql, params)
  File "/path/to/project/local/lib/python3.4/dist-packages/django/db/utils.py", line 97, in __exit__
    six.reraise(dj_exc_type, dj_exc_value, traceback)
  File "/path/to/project/local/lib/python3.4/dist-packages/django/utils/six.py", line 658, in reraise
    raise value.with_traceback(tb)
  File "/path/to/project/local/lib/python3.4/dist-packages/django/db/backends/utils.py", line 64, in execute
    return self.cursor.execute(sql, params)
  File "/path/to/project/local/lib/python3.4/dist-packages/django/db/backends/sqlite3/base.py", line 318, in execute
    return Database.Cursor.execute(self, query, params)
django.db.utils.OperationalError: disk I/O error

重点:

  1. 路径似乎是正确的。看看debug.log,我可以看到正在调用脚本。
  2. 权限应该不是问题,因为process_message是使用sudo以root身份运行的。
  3. 运行process_message.sh可以正常运行
  4. 以电子邮件用户身份运行process_message.sh也可以
  5. 通过procmail运行时出现错误。

    这是错误堆栈跟踪:

    onPaymentMethodReceived

0 个答案:

没有答案