Skip to content

Commit

Permalink
Fixed: Ref: db.command hanging with 100% CPU #2 #68
Browse files Browse the repository at this point in the history
Support for protocol 29

Update Travis.ci
  • Loading branch information
Ostico committed May 16, 2015
1 parent c917f0a commit db3d0b2
Show file tree
Hide file tree
Showing 6 changed files with 50 additions and 7 deletions.
11 changes: 9 additions & 2 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,15 +14,22 @@ after_success:
- coveralls

env:
- ORIENTDB_VERSION=2.0.8
- ORIENTDB_VERSION=2.0.7
- ORIENTDB_VERSION=2.0.6
- ORIENTDB_VERSION=2.0.5
- ORIENTDB_VERSION=2.0.4
- ORIENTDB_VERSION=2.0.3
- ORIENTDB_VERSION=2.0.2
- ORIENTDB_VERSION=2.0.1
- ORIENTDB_VERSION=2.0
- ORIENTDB_VERSION=1.7.10
- ORIENTDB_VERSION=1.7.8
- ORIENTDB_VERSION=1.7.7
- ORIENTDB_VERSION=1.7.4

matrix:
allow_failures:
# - env: ORIENTDB_VERSION=1.7.7
- ORIENTDB_VERSION=1.7.10
- ORIENTDB_VERSION=1.7.8
- ORIENTDB_VERSION=1.7.7
- ORIENTDB_VERSION=1.7.4
4 changes: 2 additions & 2 deletions pyorient/constants.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@
# Driver Constants
#
NAME = "OrientDB Python binary client (pyorient)"
VERSION = "1.4"
SUPPORTED_PROTOCOL = 28
VERSION = "1.4.1"
SUPPORTED_PROTOCOL = 29

#
# Binary Types
Expand Down
4 changes: 2 additions & 2 deletions pyorient/messages/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -269,14 +269,14 @@ def _encode_field(field):
elif t['type'] == BYTES:
_content = struct.pack("!i", len(v)) + v
elif t['type'] == STRING:
if sys.version_info.major >= 3:
if sys.version_info[0] >= 3:
if isinstance( v, str ):
v = v.encode('utf-8')
_content = struct.pack("!i", len(v)) + v
elif t['type'] == STRINGS:
_content = b''
for s in v:
if sys.version_info.major >= 3:
if sys.version_info[0] >= 3:
if isinstance( s, str ):
s = s.encode('utf-8')
_content += struct.pack("!i", len(s)) + s
Expand Down
3 changes: 3 additions & 0 deletions pyorient/messages/commands.py
Original file line number Diff line number Diff line change
Expand Up @@ -179,6 +179,9 @@ def _read_sync(self):
response_type = response_type.decode()
res = []
if response_type == 'n':
self._append( FIELD_CHAR )
super( CommandMessage, self ).fetch_response(True)
# end Line \x00
return None
elif response_type == 'r':
res = [ self._read_record() ]
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
from setuptools import setup

setup(name='pyorient',
version='1.4',
version='1.4.1',
author='Niko Usai <mogui83@gmail.com>, Domenico Lupinetti <ostico@gmail.com>',
description='OrientDB native client library',
long_description=open('README.md').read(),
Expand Down
33 changes: 33 additions & 0 deletions test/test_new_Iface.py
Original file line number Diff line number Diff line change
Expand Up @@ -237,6 +237,39 @@ def test_use_of_dir(self):
client.connect("root", "root")
dir(client)

def test_alter_statement(self):
client = pyorient.OrientDB("localhost", 2424)
client.connect("root", "root")

db_name = "test_1234_db"
try:
client.db_drop(db_name)
except pyorient.PyOrientCommandException as e:
print(e)
finally:
db = client.db_create(db_name, pyorient.DB_TYPE_GRAPH,
pyorient.STORAGE_TYPE_MEMORY)

cluster_info = client.db_open(
db_name, "admin", "admin", pyorient.DB_TYPE_GRAPH, ""
)

client.command( "create class obj" )
client.command( "create property obj._KEY string" )
client.command( "alter property obj._KEY mandatory true" )
with self.assertRaises( pyorient.PyOrientCommandException ) as context:
client.command( "create index KEY on obj _KEY unique" )

import re
match_obj = re.match( r'(.*):.*',
str( context.exception ) )

self.assertTrue( 'Error on parsing command at position #23'
in match_obj.group(1) )

client.command( "create index KEY on obj ( _KEY ) unique" )
assert True is True


# x = CommandTestCase('test_command').run()

Expand Down

0 comments on commit db3d0b2

Please sign in to comment.