# Creating a BasicExecutionEngine schedule

**URL:** <https://forum.inductiveautomation.com/t/creating-a-basicexecutionengine-schedule/27297>\
**Category:** Ignition\
**Tags:** vision\
**Created:** [August 8, 2019, 9:51pm UTC](https://forum.inductiveautomation.com/t/creating-a-basicexecutionengine-schedule/27297 "2019-08-08T21:51:58Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![nminchin](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/nminchin/32/6911_2.png) [@nminchin](https://forum.inductiveautomation.com/u/nminchin)\
**Post date:** [August 8, 2019, 9:51pm UTC](https://forum.inductiveautomation.com/t/creating-a-basicexecutionengine-schedule/27297/1 "2019-08-08T21:51:58Z")

</div>

I’m trying to use the BasicExecutionEngine to create a tasks schedule, but I’m having issues (doesn’t help my Java knowledge is lacking).  
@pturmel ([Does Ignition have schedule events?](http://forum.inductiveautomation.com/t/does-ignition-have-schedule-events/16899/4?u=nminchin))

```auto
from java.lang import Runnable
from com.inductiveautomation.ignition.common.execution.impl import BasicExecutionEngine

class Task(Runnable):
	def run(self):
		print 'Hellooo'

s = BasicExecutionEngine()
s.schedule("task", Task, "0-59 * * * *")

```

I’m receiving the error:

```auto
Traceback (most recent call last):
  File "<buffer>", line 9, in <module>
TypeError: schedule(): 2nd arg can't be coerced to java.lang.Runnable

```

---

<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:** [August 8, 2019, 9:58pm UTC](https://forum.inductiveautomation.com/t/creating-a-basicexecutionengine-schedule/27297/2 "2019-08-08T21:58:08Z")

</div>

> [@nminchin](#):
>
> s.schedule("task", Task, "0-59 \* \* \* \*")

Python usage error. You are providing your `Task` class when you need to provide a `Task` _instance_. Your last line should look like this:

```auto
s.schedule("task", Task(), "0-59 * * * *")

```

By the way, you can put an asterisk in the minute column, too.....

---

<div class="post-metadata">

**Author:** ![nminchin](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/nminchin/32/6911_2.png) [@nminchin](https://forum.inductiveautomation.com/u/nminchin)\
**Post date:** [August 8, 2019, 10:13pm UTC](https://forum.inductiveautomation.com/t/creating-a-basicexecutionengine-schedule/27297/3 "2019-08-08T22:13:56Z")

</div>

Cheers, I thought it was going to be something silly like that 🙂

Looks like it’s working now, thanks!

If I put this code in the gateway startup script, I assume that it will run on the gateway?

Also, how would I get a reference to my BasicExecutionEngine object from another script? (I setup the schedule in my Script Console and not sure how to stop it… Also would be useful to know!)

---

<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:** [August 8, 2019, 11:43pm UTC](https://forum.inductiveautomation.com/t/creating-a-basicexecutionengine-schedule/27297/4 "2019-08-08T23:43:06Z")

</div>

So, object persistence is the kind of thing that can eat your lunch. I would use system.util.getGlobals() to maintain a true single instance, with code to shutdown any prior instance upon script restart. Something like this:

```auto
MyBEE = BasicExecutionEngine()
_g = system.util.getGlobals()
_oldBEE = _g.get('some_unique_key_for_BEE')
_g['some_unique_key_for_BEE'] = MyBEE
if _oldBEE:
    _oldBEE.shutdown()

```

Elsewhere, you can use `project.someScript.MyBEE` to access the engine. I think you keep the string returned from `.schedule()` to use with `.unSchedule()`.
