# Update either dataset or array

**URL:** <https://forum.inductiveautomation.com/t/update-either-dataset-or-array/91226>\
**Category:** Ignition\
**Created:** [May 31, 2024, 9:27pm UTC](https://forum.inductiveautomation.com/t/update-either-dataset-or-array/91226 "2024-05-31T21:27:31Z")\
**Posts on this page:** 1\
**Showing post:** 18

<div class="post-metadata">

**Author:** ![pturmel](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/pturmel/32/3295_2.png) [@pturmel](https://forum.inductiveautomation.com/u/pturmel)\
**Post date:** [June 3, 2024, 5:56pm UTC](https://forum.inductiveautomation.com/t/update-either-dataset-or-array/91226/18 "2024-06-03T17:56:01Z")

</div>

> [@Ryan\_Deardorff](#):
>
> ```python
> def getQueue(name, capacity=4000):
> if not system.util.getGlobals().has_key(name):
> return LinkedBlockingQueue(capacity)
> return system.util.getGlobals()[name]
> 	
> def setQueue(name, q):
> system.util.getGlobals()[name] = q
> 
> ```

Those are racy and prone to memory leaks. Always use `.setdefault` to reliably initialize a value in a dictionary when a check for the key's presence fails. When the value is an object that will be used all over the library, use the `.setdefault` technique to establish it as a top-level variable in the library.

Study this topic for the techniques needed to avoid crashing your gateway:

> [@Java concurrent queue for tag change scripts](https://forum.inductiveautomation.com/t/topic/82044/1):
>
> Continuing the discussion from [[SOLVED] Are tag Value Changed scripts running asynchronously?](https://forum.inductiveautomation.com/t/solved-are-tag-value-changed-scripts-running-asynchronously/68704/5): We've got code in our standard library that I need to log a value change on a tag and then associate various data points with that value change. The value is located in a UDT, and because this is part of our "standard" library we use for our customers, the number of tags is variable and quite possibly numerous so having a gateway tag event script isn't feasible for this solution. I was reading up on …

If you cannot use my `globalVarMap()`, you have to approximate it with an extra layer in `system.util.getGlobals()`.

---

_[View the full topic](https://forum.inductiveautomation.com/t/update-either-dataset-or-array/91226)._
