Skip to content
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

Uploading while printing #357

Closed
Salandora opened this issue Jan 24, 2014 · 5 comments

Comments

Projects
None yet
2 participants
@Salandora
Copy link
Collaborator

commented Jan 24, 2014

Hello,

I'm using the devel branch, and encountered the following problem.
When uploading a gcode file while octoprint is printing, it stops streaming the commands to the printer so that the printer stops moving. After a couple of seconds everything runs as usual.

@foosel

This comment has been minimized.

Copy link
Owner

commented Jan 24, 2014

Is this on a raspberry pi? Because it might just be a bit too much to
handle for the little guy. File upload is rather io intense, as is
printing, so you might just be hitting the limit of what is possible there.

@Salandora

This comment has been minimized.

Copy link
Collaborator Author

commented Jan 24, 2014

It's on an Olimex Olinuxino A20, but might be because of the IO processing, i will try to investigate it when I have some time left.

@Salandora

This comment has been minimized.

Copy link
Collaborator Author

commented Jan 26, 2014

Hello,

I guess I found the problem, it's because of the gcode interpreter, the analysis is running as a thread, this thread seems to slow down other operations. As I know python has no option to priorise a thread.

Any Ideas how to solve the problem?
Because for me it's the first time using python, i don't know of the posibillities.

Is it an option to make the analysis an own program and just parsing the metadata in octoprint?

I hope my english is readable, I haven't used it for nearly 5 years now...

@Salandora

This comment has been minimized.

Copy link
Collaborator Author

commented Jan 27, 2014

I investigated the problem further and found the problem:

While printing the analysis of gcode files should have been paused.
This isn*t working correctly.

In gcodefiles.py there is a "def work(self)" function in there is the problem:

while True:
    self._active.wait()

    if aborted is not None:
        filename = aborted
        aborted = None
        self._logger.debug("Got an aborted analysis job for file %s, processing this instead of first item in queue" % filename)
    else:
        (priority, filename) = self._queue.get()
        self._logger.debug("Processing file %s from queue (priority %d)" % (filename, priority))

needs to be changed into:

while True:

    if aborted is not None:
        filename = aborted
        aborted = None
        self._logger.debug("Got an aborted analysis job for file %s, processing this instead of first item in queue" % filename)
    else:
        (priority, filename) = self._queue.get()
        self._logger.debug("Processing file %s from queue (priority %d)" % (filename, priority))

    self._active.wait()

Explaination:
"(priority, filename) = self._queue.get()"
is blocking the whole function until it has an item in the queue.
So if you start printing the "self._active.wait()" has already been passed and the queue is blocking,
if you upload a file it gets analysed no matter if the analysis is paused or not.

@foosel

This comment has been minimized.

Copy link
Owner

commented Jan 27, 2014

Thanks for spotting this. I was wondering why gcode analysis might be to blame here, since it's -- as you pointed out -- actually supposed to be paused while printing. Didn't yet come around to take a closer look though (busy on another branch), so thanks for doing that for me :)

foosel added a commit that referenced this issue Feb 15, 2014

Bugfix: Do not run gcode analyzer when a print is ongoing
Evaluate active flag on gcode analyzer AFTER fetching an item from the work queue, otherwise it will always start working once it finds something if the active flag was true once but then switched to false while the queue was still empty.

Thanks to @Salandora for spotting this.

Fixes #357

@foosel foosel closed this Feb 15, 2014

foosel added a commit that referenced this issue Feb 24, 2014

Bugfix: Do not run gcode analyzer when a print is ongoing
Evaluate active flag on gcode analyzer AFTER fetching an item from the work queue, otherwise it will always start working once it finds something if the active flag was true once but then switched to false while the queue was still empty.  Thanks to @Salandora for spotting this.

Fixes #357

(manually cherry-picked from 592f3dc)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.