Skip to content

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

@spalatofhi

Description

@spalatofhi

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()

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions