Skip to content

Commit

Permalink
fixes #6
Browse files Browse the repository at this point in the history
  • Loading branch information
prashanthellina committed Apr 26, 2014
1 parent 7e4f99a commit 5777c07
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 15 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@
__pycache__/
*.py[cod]

*.sw[op]

# C extensions
*.so

Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@
url="https://github.com/prashanthellina/vwserver",
license='MIT License',
install_requires=[
'decorator',
'websocket-client',
'decorator',
'gevent',
'funcserver',
],
Expand Down
24 changes: 10 additions & 14 deletions vwserver/vwserver.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from gevent import monkey; monkey.patch_socket()
from gevent import monkey; monkey.patch_all()

import time
import os
Expand All @@ -9,11 +9,10 @@
import socket
import threading
import copy
from functools import wraps

from decorator import decorator
import tornado
import websocket
from decorator import decorator
from funcserver import RPCServer, RPCClient

VWOPTIONS = {
Expand Down Expand Up @@ -228,20 +227,17 @@ def destroy(self):
shutil.rmtree(self.data_dir)

@decorator
def ensurevw(fn):
@wraps(fn)
def wfn(self, vw, *args, **kwargs):
data_dir = os.path.join(self.data_dir, vw)
def ensurevw(fn, vw, *args, **kwargs):
data_dir = os.path.join(self.data_dir, vw)

if vw not in self.vws and not VW.exists(vw, data_dir):
raise Exception('vw "%s" does not exist' % vw)
if vw not in self.vws and not VW.exists(vw, data_dir):
raise Exception('vw "%s" does not exist' % vw)

if vw not in self.vws:
self.vws[vw] = VW(vw, data_dir, log=self.log,
on_fatal_failure=lambda: self.unload(vw))
if vw not in self.vws:
self.vws[vw] = VW(vw, data_dir, log=self.log,
on_fatal_failure=lambda: self.unload(vw))

return fn(self, self.vws[vw], *args, **kwargs)
return wfn
return fn(self, self.vws[vw], *args, **kwargs)

class VWAPI(object):
def __init__(self, data_dir):
Expand Down

0 comments on commit 5777c07

Please sign in to comment.