-
Notifications
You must be signed in to change notification settings - Fork 38
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Re-running script with imported modules may crash #104
Comments
I tried a less sophisticated version of module unloading a year or two ago and abandoned it because I had trouble getting it to work. At the time I felt there was something weird about the Python execution environment, but never figured out if I was right about that. It seems like you're code should be really close to working, and it's a needed feature. What happens if you force the script to run using CQGI by adding something like this at the bottom? result = cq.Workplane('XY').box(1, 1, 1)
show_object(result) |
Here's the issue related to that earlier attempt. I think CQGI takes care of it when you're displaying a model, but I didn't think about the cases where someone doesn't run |
I agree!, I think it's necessary to have a pure python method of running scripts that works inside FreeCAD, and outside, so the same script can be easily debugged in FreeCAD without "switching" code on and off, or having If anyone else experiences this issue, please "+1" 👍 this issue, or comment here. It may be isolated to @jmwright please let me know if you're concerned about this issue, and I'll prioritise finding a root cause... otherwise this is fairly low on my priority list |
@fragmuffin This is the next item on my CadQuery list. I'm hoping we can figure it out, but if it ends up being a huge time sink, and it only causes problems in a few edge cases, it may be forced down the priority list. It's unfortunate, but there's so much going on with CadQuery right now, and there's just not enough time for everything. |
By unfortunate I mean that it's unfortunate that I don't have more time. Having a lot going on in the CadQuery community is a good thing. |
@fragmuffin I've started looking into this and I can reproduce the error, I'm just not sure where it's coming from yet. I swapped
|
@jmwright this issue is at the top of my cadquery todo list; I haven't forgotten, I've just got a few other projects I need to finish first. To clarify point 2: |
FreeCAD has always seemed a little weird about importing.
Correct. My next step was going to be to check the script's temporary file to make sure it's changing, but I have no reason to believe that mechanism is broken. |
CQGI (CadQuery Gateway Interface) uses the Python ast module to execute a script in a constructed environment. I'm wondering if I should switch to that way of running scripts. https://github.com/dcowden/cadquery/blob/master/cadquery/cqgi.py#L109 |
@jmwright for an example , have a look at the docker-cli branch-- cq_cmd.py has most of the boilerplate you need to use cqgi to run scripts. the cqgi part is only a few lines, but there tends to be other common code like setting extra paramters, checking output formats, etc. As an example, when writing cq_cmd.py, it was clear to me that some kind of 'check that this export format is valid' function, and a function to set parameters using a dictionary, would be nice additions to cqgi |
Steps to re-create
~/temp/my_module/__init__.py
with contents...FreeCAD
, and start a newcadquery
script, copy this in...F2
)F2
)Expectation
log output should show "hi there" twice, having run the script successfully twice
Actual Results
The script runs successfully the first time, but has trouble with the value of
logging
on the second run.Work-around
Close FreeCAD, then re-open it
Isolated to
logging
?root-cause not determined yet, so I don't know
Introduced by: #103 (sorry 😟)
The text was updated successfully, but these errors were encountered: