# Timer (from threading) doesn't write tag after a certain time (delay)

**URL:** <https://forum.inductiveautomation.com/t/timer-from-threading-doesnt-write-tag-after-a-certain-time-delay/92994>\
**Category:** Ignition\
**Tags:** ignition79, scripting\
**Created:** [July 10, 2024, 7:59am UTC](https://forum.inductiveautomation.com/t/timer-from-threading-doesnt-write-tag-after-a-certain-time-delay/92994 "2024-07-10T07:59:30Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![lcies](https://avatars.discourse-cdn.com/v4/letter/l/b3f665/32.png) [@lcies](https://forum.inductiveautomation.com/u/lcies)\
**Post date:** [July 10, 2024, 7:59am UTC](https://forum.inductiveautomation.com/t/timer-from-threading-doesnt-write-tag-after-a-certain-time-delay/92994/1 "2024-07-10T07:59:30Z")

</div>

Hello,

in practice, i would need to write an output flag (Done) to True after a certain time (delay) that the input flag (Trigger) has gone to True:

 ![image](https://us1.discourse-cdn.com/inductiveautomation/original/3X/1/e/1e1032540fb352fdf53a62b98ccb5bcb93891932.png)

 ![image](https://us1.discourse-cdn.com/inductiveautomation/original/3X/b/8/b8004ed6a8569e9698abebfb19ca415208b64717.png)

The input flag (Trigger) is reset but the second one (Done, the delayed one) is not set. From the logs you can see that both functions are executed.. but actually only one of the two tags is written (the firts one, Trigger).  
See wrapper.log:

![image](https://us1.discourse-cdn.com/inductiveautomation/original/3X/d/b/db2227d7cc0a1be898d8dcea9b8d22583af5977b.png)

So, the script works but the output tag (Done) is not set to True.. as if the gateway ignored the writing..

- Why this behavior?
- How can i fix it?

Thanks in advance.

---

<div class="post-metadata">

**Author:** ![SolarNomad](https://avatars.discourse-cdn.com/v4/letter/s/34f0e0/32.png) [@SolarNomad](https://forum.inductiveautomation.com/u/SolarNomad)\
**Post date:** [July 11, 2024, 3:23am UTC](https://forum.inductiveautomation.com/t/timer-from-threading-doesnt-write-tag-after-a-certain-time-delay/92994/2 "2024-07-11T03:23:50Z")

</div>

The tag path that you are feeding the write function does not look correct. Try copying the full tag path to the "Done" flag value from the tag browser and pasting it on line 10 in place of "[.]Done"

To simplify this problem you could also test writing to the tag with the script console with a much simpler script

---

<div class="post-metadata">

**Author:** ![lcies](https://avatars.discourse-cdn.com/v4/letter/l/b3f665/32.png) [@lcies](https://forum.inductiveautomation.com/u/lcies)\
**Post date:** [July 11, 2024, 10:24am UTC](https://forum.inductiveautomation.com/t/timer-from-threading-doesnt-write-tag-after-a-certain-time-delay/92994/3 "2024-07-11T10:24:08Z")

</div>

> [@SolarNomad](#):
>
> Try copying the full tag path to the "Done" flag value from the tag browser and pasting it on line 10 in place of "[.]Done

I try to do as you suggested.. and great, it works:

```python
	if currentValue.value != previousValue.value and not initialChange and currentValue.value:
	
		from threading import Timer
		from system.tag import read, write

		def wrapper():
			write("[default]_TEST/Do_Test/Done", True)
			print "stop t1"
		
		def reset():
			write(tagPath, False)
			print "stop t2"	
		
		
		d = read("[.]Delay").value
		
		t1 = Timer(d, wrapper)
		t1.start()
		
		t2 = Timer(1.0, reset)
		t2.start()
		print "start t1, t2"

```

I think that once you run the _write_ function in a separate thread, it needs a full path (provider + tag path) to work properly.  
If you remove the provider the _write_ function no longer works.

Thanks 👍
