I'm getting a error for doing this, i have no idea why.. works perfectly fine in idle, they are in same directory and everything, i tried adding __init__.py since it needed that in a sub directory to import scripts from it but that did not help either
I'm lost at this point because i never had this problem before >_>
importing another .py file from same folder?
i know but i though the source python was running a older version.
My main addon needs to import another .py file in same directory (the addon directory) top of the line in my addon i have, "import sql" in the same directory as addon i have sql.py witch is the file im trying to import however i just get a error.. on load with "no module named etc.."
My main addon needs to import another .py file in same directory (the addon directory) top of the line in my addon i have, "import sql" in the same directory as addon i have sql.py witch is the file im trying to import however i just get a error.. on load with "no module named etc.."
-Tuck
I've got a debug message (print) in my sql.py and for some reason this importing does not work correctly on first load however on the 2nd reload it works? im guessing this is a bug..
I did not change my script at all bellow i just typed sp_load and sp_unload

and for some reason my sql.py doesnt work as intended most of the time, as it actually does in idle >_>
I did not change my script at all bellow i just typed sp_load and sp_unload

and for some reason my sql.py doesnt work as intended most of the time, as it actually does in idle >_>
-Tuck
I'm getting pretty frustrated over this -.- i created and tested my script in idle and it worked just fine in this it's rather really weird >_>
If i have this line where should my data.db suppose to be >_>, i cannot find it anywhere >_> idle would put it next to the .py files as im intending to do>_>
My sql.py looks like this, bellow. The idea is it runs in a seperate thread side by side with main thread and do sql stuff, and it works perfectly fine in idle however i cant figure out why the heck it fucks up on source python -.-
If i have this line where should my data.db suppose to be >_>, i cannot find it anywhere >_> idle would put it next to the .py files as im intending to do>_>
Syntax: Select all
conn = sqlite3.connect('data.db')
My sql.py looks like this, bellow. The idea is it runs in a seperate thread side by side with main thread and do sql stuff, and it works perfectly fine in idle however i cant figure out why the heck it fucks up on source python -.-
Syntax: Select all
import threading
import queue
import sqlite3
_exec = [queue.Queue(), queue.Queue()]
_close = False
_commit = False
class _thread(threading.Thread):
def run(self):
global _exec
global _close
global _commit
conn = sqlite3.connect('data.db')
c = conn.cursor()
#INSERT IF TABLE DOES NOT EXISTS ETC..
conn.commit()
while True:
if _exec[0].qsize() > 0:
wildcard, sql_statement, func, args = _exec[0].get()
if wildcard:
obj = c.execute(*sql_statement)
else:
obj = c.execute(sql_statement)
if not (func is None):
func(obj, *args)
_exec[0].task_done()
elif _exec[1].qsize() > 0:
wildcard, sql_statement, func, args = _exec[1].get()
if wildcard:
obj = c.execute(*sql_statement)
else:
obj = c.execute(sql_statement)
if not (func is None):
func(obj, *args)
_exec[1].task_done()
if _close and (_exec[0].qsize() == 0 and
_exec[1].qsize() == 0):
conn.commit()
conn.close()
print('## SQL ## - Thread closed.')
break
elif not _close and (_exec[0].qsize() == 0 and
_exec[1].qsize() == 0):
if _commit:
print('## SQL ## - Thread committing.')
conn.commit()
print('## SQL ## - Thread committed.')
_commit = False
_t = _thread()
_t.start()
print('## SQL ## - 1.')
def execution(priority, wildcard, sql_statement, func, *args):
global _exec
_exec[(priority - 1)].put((wildcard, sql_statement, func, args))
def close():
global _close
_close = True
def commit():
global _commit
_commit = True
-Tuck
-
- Developer
- Posts: 168
- Joined: Sat Jul 07, 2012 1:58 am
This might have something to do with the fact that I just realized sqlite3.dll isn't being loaded by Source.Python. This will be fixed in an update soon. I am actually updating the Python distribution from 3.3 alpha2 to 3.3 beta 2.
Also of note, we had very strange issues with hibernation and threading / timings. I would suggest you force sv_hibernate_when_empty to 0 and test.
Also of note, we had very strange issues with hibernation and threading / timings. I would suggest you force sv_hibernate_when_empty to 0 and test.
Return to “Plugin Development Support”
Who is online
Users browsing this forum: No registered users and 50 guests