Skip to content
This repository was archived by the owner on Oct 1, 2020. It is now read-only.
This repository was archived by the owner on Oct 1, 2020. It is now read-only.

PgQ python framework can not be used anymore with python2.4 #30

@dsaque

Description

@dsaque

Hello,

Since version 3.1.5, PgQ python framework can not be used anymore with python2.4.
The use of finally instruction in admin.py file is blocking.

-bash-3.2$ ./QMover_axfrak4_pgq_emv_newtrans_axis2proxy_QA_RHA.py QMOVER.ini --stop
Traceback (most recent call last):
File "./QMover_axfrak4_pgq_emv_newtrans_axis2proxy_QA_RHA.py", line 11, in ?
from qmover import QueueMover
File "/var/lib/pgsql/9.2/data/PgQ_ReplicationRHA_RC6/qmover.py", line 27, in ?
import pgq
File "/usr/lib64/python2.4/site-packages/pgq/init.py", line 14, in ?
import pgq.cascade.admin
File "/usr/lib64/python2.4/site-packages/pgq/cascade/admin.py", line 495
finally:
^
SyntaxError: invalid syntax

In order to keep compatibility, is it possible to use the following code in python/pgq/cascade/admin.py :

def load_node_status (self, name, location):
""" Load node info & status """
# must be thread-safe (!)
if not self.node_alive(name):
node = NodeInfo(self.queue_name, None, node_name = name)
return node
try:
db = None
db = skytools.connect_database (location)
db.set_isolation_level (skytools.I_AUTOCOMMIT)
curs = db.cursor()
curs.execute("select * from pgq_node.get_node_info(%s)", [self.queue_name])
node = NodeInfo(self.queue_name, curs.fetchone())
node.load_status(curs)
self.load_extra_status(curs, node)
if db: db.close()
except DBError, d:
msg = str(d).strip().split('\n', 1)[0].strip()
print('Node %r failure: %s' % (name, msg))
node = NodeInfo(self.queue_name, None, node_name = name)
if db: db.close()
return node

instead of:

def load_node_status (self, name, location):
""" Load node info & status """
# must be thread-safe (!)
if not self.node_alive(name):
node = NodeInfo(self.queue_name, None, node_name = name)
return node
try:
db = None
db = skytools.connect_database (location)
db.set_isolation_level (skytools.I_AUTOCOMMIT)
curs = db.cursor()
curs.execute("select * from pgq_node.get_node_info(%s)", [self.queue_name])
node = NodeInfo(self.queue_name, curs.fetchone())
node.load_status(curs)
self.load_extra_status(curs, node)
except DBError, d:
msg = str(d).strip().split('\n', 1)[0].strip()
print('Node %r failure: %s' % (name, msg))
node = NodeInfo(self.queue_name, None, node_name = name)
finally:
if db: db.close()
return node

Best Regards.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions