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

How to clear task and create a new task with same name? #100

Closed
spalatofhi opened this issue May 15, 2020 · 0 comments · Fixed by #149
Closed

How to clear task and create a new task with same name? #100

spalatofhi opened this issue May 15, 2020 · 0 comments · Fixed by #149

Comments

@spalatofhi
Copy link

spalatofhi commented May 15, 2020

I'm building a GUI that can control state of a task. As such, the channels etc. can change (when the task is stopped, of course). In the process of doing this, I end up creating tasks with the same name multiple time. This raises an error (status code -200089), as expected. However, I would like to destroy the current task, and build a new one. However, I cannot do this as an error -200088 is raised in the meantime, thought I do not understand where.

Here is an example. I would expect the this to print "Tried to create duplicate task" and "finishing". Instead, an error -200088 is raised in a Task.__del__, somewhere in between the two print statements.

from nidaqmx import Task, DaqError
from nidaqmx.error_codes import DAQmxErrors

t = Task("task")
try:
    u = Task("task")
except DaqError as err:
    if err.error_code == DAQmxErrors.DUPLICATE_TASK.value:
        print("Tried to create duplicate task")
    else:
        raise
finally:
    print("finishing")
    t.close()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant