Bench stops when I use 'from * import *'

Hello, I am making a customization to a page, trying to include the attachments in an amended sales/purchase order. The feature is successfully implemented by editing documents.py accordingly. However when I use > from frappe.desk.form.load import get_attachments Bench stops and I get this error. The same error does not occur and everything works fine if I put the get_attachments function explicitly in script. I think it is a better approach to import than rewrite the function so I am looking for a fix for this.

Any help would be appreciated. Thanks.
@neilLasrado

Hello Yomi,

It seems you are trying to access the redis localhost:11000 which is already used by the bench for redis_cache so in case you are trying to access which causes bench to shutdown.

Hi Shreyasp,

I access my site normally with my ipaddresss, which is not localhost. I disabled the 127.0.0.1 bind address and I have my designated ipadress that I use to access my site.

Also, this error occurs only if I have that particular from…import in my script. If I comment out that particular from import, bench is up and running and there are other import statements in the file as well that work without any issues.

@Yomi

Can you tell me what specific import statement in your python file leads to stop the bench?

from frappe.desk.form.load import getattachments

@Yomi

As per the file there is function definition for get_attachments(…) while you seem reference getattachments.

Sorry that seems to be a typo from me in this post. I use get_attachments. Here’s a screenshot of that portion of the script, taken directly from my documents.py. The second to the last one is the one that stops bench.

This issue is fixed. It was resolved by placing the > from … import statement within the new function defined in the script.