我有一个脚本,它可以按预期工作,但是最后,当它终止时,会产生此错误:
class AddOn(models.Model):
name = models.CharField(max_length=100)
class Invoice(models.Model):
additional_options = models.ManyToManyField(AddOn)
def save(self, *args, **kwargs):
super().save()
# this prints the objects that were selected prior to the save.
# this isn't helpful if the selected objects have changed.
print(self.additional_options.all())
代码是:
interact: spawn id exp4 not open
while executing
"interact"
(file "./pippo.sh" line 8)
答案 0 :(得分:0)
如果当您的expect_background
发送quit\n
时,生成的进程退出了,这是正常的。这将关闭将期望连接到进程的文件描述符( spawn id ),因此interact
在尝试继续读取(或写入)进程时将失败。
您可以通过在后台命令中添加一行以检测文件结束并在退出时退出该行来抑制该错误:
expect_background {
"Now recording all stats to file every {0}ms" \
{ sleep 10 ; send "stats record stop\n" ; \
expect "Stopped recording stats to file." \
{ sleep 5 ; send "quit\n"; \
expect eof exit } } }