# Importing time module bug

**URL:** <https://forum.inductiveautomation.com/t/importing-time-module-bug/33906>\
**Category:** Ignition\
**Tags:** scripting, ignition80\
**Created:** [April 14, 2020, 12:48am UTC](https://forum.inductiveautomation.com/t/importing-time-module-bug/33906 "2020-04-14T00:48:29Z")\
**Posts on this page:** 1\
**Showing post:** 5

<div class="post-metadata">

**Author:** ![cesrom](https://avatars.discourse-cdn.com/v4/letter/c/ea666f/32.png) [@cesrom](https://forum.inductiveautomation.com/u/cesrom)\
**Post date:** [April 14, 2020, 8:02pm UTC](https://forum.inductiveautomation.com/t/importing-time-module-bug/33906/5 "2020-04-14T20:02:25Z")

</div>

I tested the following code, and hereby I confirm that switching to `java.lang.Thread` solves the problem experienced with Python’s `time` module.

```auto
import system.date

from java.lang import Exception as JException, Thread

def java_sleep():
    print 'Thread.sleep'
    print system.date.now()
    Thread.sleep(5000)
    print system.date.now()

def py_sleep():
    print 'time.sleep'
    import time
    print system.date.now()
    time.sleep(5)
    print system.date.now()

try:
    java_sleep()
    py_sleep()
except JException, e:
    print e.message

```

Output:

```auto
>>>>
Thread.sleep
Tue Apr 14 22:01:02 CEST 2020
Tue Apr 14 22:01:07 CEST 2020
time.sleep
Cannot create PyString with non-byte value
>>>>

```

But still mind-boggling that after multiple attempts calling Python’s `time.sleep` does work without throwing an error; and after one successful execution the error occurs no more.

I’ll be making the switch to `Thread.sleep`.

Thanks, @KathyApplebaum and @pturmel.

---

_[View the full topic](https://forum.inductiveautomation.com/t/importing-time-module-bug/33906)._
