# No output on first run for scripts called from script console (decorator issue ?)

**URL:** <https://forum.inductiveautomation.com/t/no-output-on-first-run-for-scripts-called-from-script-console-decorator-issue/59245>\
**Category:** Ignition\
**Created:** [May 5, 2022, 12:39pm UTC](https://forum.inductiveautomation.com/t/no-output-on-first-run-for-scripts-called-from-script-console-decorator-issue/59245 "2022-05-05T12:39:28Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![pascal.fragnoud](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/pascal.fragnoud/32/24728_2.png) [@pascal.fragnoud](https://forum.inductiveautomation.com/u/pascal.fragnoud)\
**Post date:** [May 5, 2022, 12:39pm UTC](https://forum.inductiveautomation.com/t/no-output-on-first-run-for-scripts-called-from-script-console-decorator-issue/59245/1 "2022-05-05T12:39:28Z")

</div>

Hello folks,

I’m kind of weird out by the script console behavior:  
The first execution doesn’t print anything, and subsequent ones work perfectly.  
But not in every case.

Here’s when it happens:  
I have this in a package:

```python
def test(func):
	def wrapper():
		try:
			func()
		except AssertionError as e:
			message = "failed ({})".format(e)
		else:
			message = "passed"
		return message
	return wrapper

```

and I define tests like this:

```python
@test
def test_func_what():
	data = somePackage.func()
	expected = "what I expect"
	assert data == expected, "expected {}, got {}".format(expected, data)

```

It does run every time I hit ‘execute’ (I can see test tags being created for example), but doesn’t print anything on the first run, and works perfectly after that.

now, this:

```python
def bar(func):
	def wrapper():
		try:
			func()
		except:
			m = "bar"
		else:
			m = "foo"
		return m
	return wrapper

@bar
def foo():
	raise ValueError

```

Doesn’t trigger this behavior and prints correctly every time.

I should also mention that when defining tests and the decorator in the console, this doesn’t happen.

What am I missing ?

---

<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:** [May 5, 2022, 5:30pm UTC](https://forum.inductiveautomation.com/t/no-output-on-first-run-for-scripts-called-from-script-console-decorator-issue/59245/2 "2022-05-05T17:30:48Z")

</div>

What version are you using/am I missing a step?  
This works first-time for me, on ~8.1.18:

 ![image](https://us1.discourse-cdn.com/inductiveautomation/original/3X/7/6/76d4031e0b6ba5ea73fef51d026c67a08f1ea600.png)

---

<div class="post-metadata">

**Author:** ![pascal.fragnoud](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/pascal.fragnoud/32/24728_2.png) [@pascal.fragnoud](https://forum.inductiveautomation.com/u/pascal.fragnoud)\
**Post date:** [May 5, 2022, 5:52pm UTC](https://forum.inductiveautomation.com/t/no-output-on-first-run-for-scripts-called-from-script-console-decorator-issue/59245/3 "2022-05-05T17:52:55Z")

</div>

I’m on 8.1.10.

But your screenshot show a scenario that works for me to. Can you try putting the tested function in the same package as the decorator’s definition, then call that function from the console ?

---

<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:** [May 5, 2022, 5:57pm UTC](https://forum.inductiveautomation.com/t/no-output-on-first-run-for-scripts-called-from-script-console-decorator-issue/59245/4 "2022-05-05T17:57:51Z")

</div>

Also seems to work:

 ![image](https://us1.discourse-cdn.com/inductiveautomation/original/3X/c/d/cd2dc9c3d86a1c2d42563154ac953bfe0085943d.png)  
Even if I invoke directly from the interpreter:  
 ![image](https://us1.discourse-cdn.com/inductiveautomation/original/3X/7/c/7c56b1be22758ac522211b542925d68c1ea0ff22.png)

---

<div class="post-metadata">

**Author:** ![pascal.fragnoud](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/pascal.fragnoud/32/24728_2.png) [@pascal.fragnoud](https://forum.inductiveautomation.com/u/pascal.fragnoud)\
**Post date:** [May 5, 2022, 6:10pm UTC](https://forum.inductiveautomation.com/t/no-output-on-first-run-for-scripts-called-from-script-console-decorator-issue/59245/5 "2022-05-05T18:10:17Z")

</div>

Well…  
It doesn’t work for me 😕

---

<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:** [May 5, 2022, 6:18pm UTC](https://forum.inductiveautomation.com/t/no-output-on-first-run-for-scripts-called-from-script-console-decorator-issue/59245/6 "2022-05-05T18:18:46Z")

</div>

I think there were some fixes to how the script console imports packages/scripts. I’d upgrade when you’re able to.

---

<div class="post-metadata">

**Author:** ![josborn](https://avatars.discourse-cdn.com/v4/letter/j/4bbf92/32.png) [@josborn](https://forum.inductiveautomation.com/u/josborn)\
**Post date:** [May 5, 2022, 8:47pm UTC](https://forum.inductiveautomation.com/t/no-output-on-first-run-for-scripts-called-from-script-console-decorator-issue/59245/7 "2022-05-05T20:47:18Z")

</div>

Also works for me in 8.1.13.
