# Gateway Shared Script not updated after save an Publish

**URL:** <https://forum.inductiveautomation.com/t/gateway-shared-script-not-updated-after-save-an-publish/27645>\
**Category:** Ignition\
**Tags:** ignition79, scripting\
**Created:** [August 21, 2019, 8:38pm UTC](https://forum.inductiveautomation.com/t/gateway-shared-script-not-updated-after-save-an-publish/27645 "2019-08-21T20:38:06Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![GreggCavazos](https://avatars.discourse-cdn.com/v4/letter/g/90db22/32.png) [@GreggCavazos](https://forum.inductiveautomation.com/u/GreggCavazos)\
**Post date:** [August 21, 2019, 8:38pm UTC](https://forum.inductiveautomation.com/t/gateway-shared-script-not-updated-after-save-an-publish/27645/1 "2019-08-21T20:38:06Z")

</div>

We are experiencing a weird behavior I haven’t seen before. We have some gateway scripts, one of them we have a function to send an email as below.

```auto
def sendEmail (subject,body,sender, recipients, server):
	try:
		system.net.sendEmail(server, sender, subject, body, 0, recipients)
	except Exception, ex:
		messagetoSend = "Error sending email: " + str(ex.message)
		shared.GW_Scripts.LogErrorMessage("GW_Scripts.EmailScript", messagetoSend)

```

we have some tags that trigger events to call the function below.

```auto
def CallBadPalletNotification(tagPath):
	try:
		recipients = ['emails']
		sender = "email@company.com"
		server = "mail.server"
		
                " ***Do something***"
		subject = "A possible bad pallet was detected in line " + str(currentLine)
		body = "A possible \"Bad Pallet\" was detected \r\n"

		  " ***Do more stuff***"

		shared.EmailScript.sendEmail(subject,body,sender,recipients,server)
	
	except Exception, ex:
		messagetoSend = "Error preparing to send email: " + str(ex.message)
		shared.GW_Scripts.LogErrorMessage("GW_Scripts.CallBadPalletNotification", messagetoSend)

```

When we change the body contents or the recipients lists and save an publish we see the logs “restarting gateway scripts…” for both [Global] and [project].

![image](https://us1.discourse-cdn.com/inductiveautomation/original/2X/4/4ea66bffe0d9e9bc1fd360df7d4c251988ceb6ba.png)

However when we trigger an event, the recipients and body are still the previous version of the script.

Any ideas??

BTW. Ignition 7.8.4 (b2016082217)

---

<div class="post-metadata">

**Author:** ![Kevin.Herron](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/kevin.herron/32/7259_2.png) [@Kevin.Herron](https://forum.inductiveautomation.com/u/Kevin.Herron)\
**Post date:** [August 22, 2019, 11:36am UTC](https://forum.inductiveautomation.com/t/gateway-shared-script-not-updated-after-save-an-publish/27645/2 "2019-08-22T11:36:16Z")

</div>

This clearly seems like a bug, but the only thing I can suggest is to upgrade to a recent version and see if it’s fixed already. There were some issues with publishing in the past, so it’s possible.

---

<div class="post-metadata">

**Author:** ![GreggCavazos](https://avatars.discourse-cdn.com/v4/letter/g/90db22/32.png) [@GreggCavazos](https://forum.inductiveautomation.com/u/GreggCavazos)\
**Post date:** [August 22, 2019, 11:51am UTC](https://forum.inductiveautomation.com/t/gateway-shared-script-not-updated-after-save-an-publish/27645/3 "2019-08-22T11:51:21Z")

</div>

We are planing the upgrade, however we haven’t been able to find a time window that makes us feel comfortable to perform the upgrade and possible rollback if something doesn’t work.

@Kevin.Herron Do you think if we restart the gateway, the change could be published?

---

<div class="post-metadata">

**Author:** ![Kevin.Herron](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/kevin.herron/32/7259_2.png) [@Kevin.Herron](https://forum.inductiveautomation.com/u/Kevin.Herron)\
**Post date:** [August 22, 2019, 11:54am UTC](https://forum.inductiveautomation.com/t/gateway-shared-script-not-updated-after-save-an-publish/27645/4 "2019-08-22T11:54:38Z")

</div>

Yes, I think restarting the gateway is likely to work.

---

<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 22, 2019, 12:39pm UTC](https://forum.inductiveautomation.com/t/gateway-shared-script-not-updated-after-save-an-publish/27645/5 "2019-08-22T12:39:48Z")

</div>

There are also possible problems with python object lifetimes, particularly if you are importing from shared or project scripts instead of spelling them out everywhere:

> [@Some Project Resources not publishing](http://forum.inductiveautomation.com/t/some-project-resources-not-publishing/16888/3):
>
> This may be a side-effect of the fact that Ignition doesn’t/can’t track the usage and retention of python code objects throughout the gateway. This means that when your script modules have interlocking dependencies, updating one script won’t impact the code objects that other scripts have imported. You may need to make a trivial change in all of your scripts and save them all together to get it to “take”. You may also need to disable then re-enable the entire project. Consider renaming the o…
