# Perspective readAsync scoping

**URL:** <https://forum.inductiveautomation.com/t/perspective-readasync-scoping/105476>\
**Category:** Ignition\
**Tags:** perspective, ignition81\
**Created:** [April 23, 2025, 4:43pm UTC](https://forum.inductiveautomation.com/t/perspective-readasync-scoping/105476 "2025-04-23T16:43:56Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Derek\_Reees](https://avatars.discourse-cdn.com/v4/letter/d/ccd318/32.png) [@Derek\_Reees](https://forum.inductiveautomation.com/u/Derek_Reees)\
**Post date:** [April 23, 2025, 4:43pm UTC](https://forum.inductiveautomation.com/t/perspective-readasync-scoping/105476/1 "2025-04-23T16:43:56Z")

</div>

Is it possible to retain the perspective session scope in the system.tag.readAsync callback function?

In this case, I am reading a tag and trying to call the system.perspective.\* functions but I keep getting an error because there is not a session attached to the thread. Below is the test script I have on a button.

```python
def runAction(self, event):
	import system
	
	def callBack(aync):
		path = '[]SITE/Anodizing/Crew/Load Crew/Crew/Crew Info'
		data=aync[0].value
		for row in range(data.getRowCount()):
			if data.getValueAt(row,0)==self.view.params.Name and data.getValueAt(row,1)==self.view.params.EmployeeID:
				data1=system.dataset.deleteRow(data, row)
				system.tag.writeBlocking(path, data1)	
				system.perspective.closePopup(id='abrR7MU8')	
				
				
	system.tag.readAsync(['[MES_SITE_ASSET]SITE/Anodizing/Crew/Load Crew/Crew/Crew Info'], callBack)

```

Obviously this is a simple case where readBlocking is probably the best approach, but it got me thinking about this and if it is possible.

---

<div class="post-metadata">

**Author:** ![Transistor](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/transistor/32/3380_2.png) [@Transistor](https://forum.inductiveautomation.com/u/Transistor)\
**Post date:** [April 23, 2025, 4:49pm UTC](https://forum.inductiveautomation.com/t/perspective-readasync-scoping/105476/2 "2025-04-23T16:49:33Z")

</div>

I don't know what the problem is but why have you got `import system` in there? The system functions are automatically available. They're built-in.

---

<div class="post-metadata">

**Author:** ![Derek\_Reees](https://avatars.discourse-cdn.com/v4/letter/d/ccd318/32.png) [@Derek\_Reees](https://forum.inductiveautomation.com/u/Derek_Reees)\
**Post date:** [April 23, 2025, 4:57pm UTC](https://forum.inductiveautomation.com/t/perspective-readasync-scoping/105476/3 "2025-04-23T16:57:32Z")

</div>

It was a carry-over from some other testing I was trying based on another thread. I just forgot to delete it out.

---

<div class="post-metadata">

**Author:** ![paul-griffith](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/paul-griffith/32/37249_2.png) [@paul-griffith](https://forum.inductiveautomation.com/u/paul-griffith)\
**Post date:** [April 23, 2025, 5:15pm UTC](https://forum.inductiveautomation.com/t/perspective-readasync-scoping/105476/4 "2025-04-23T17:15:26Z")

</div>

You can capture values from the outer scope when you define a function, by using default arguments:

```python
def runAction(self, event):
	
	def callBack(aync, sessionId=self.session.id, pageId=self.page.id):
		path = '[]SITE/Anodizing/Crew/Load Crew/Crew/Crew Info'
		data=aync[0].value
		for row in range(data.getRowCount()):
			if data.getValueAt(row,0)==self.view.params.Name and data.getValueAt(row,1)==self.view.params.EmployeeID:
				data1=system.dataset.deleteRow(data, row)
				system.tag.writeBlocking(path, data1)	
				system.perspective.closePopup(id='abrR7MU8', sessionId=sessionId, pageId=pageId)
				
	system.tag.readAsync(['[MES_SITE_ASSET]SITE/Anodizing/Crew/Load Crew/Crew/Crew Info'], callBack)

```
