Skip to content

Commit

Permalink
Attempt to add cwd to path when consumer fails. Refs #83.
Browse files Browse the repository at this point in the history
  • Loading branch information
coleifer committed Jan 15, 2015
1 parent 91cd598 commit 9cd4724
Showing 1 changed file with 14 additions and 5 deletions.
19 changes: 14 additions & 5 deletions huey/bin/huey_consumer.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import logging
import optparse
import os
import sys
from logging.handlers import RotatingFileHandler

Expand Down Expand Up @@ -78,6 +79,18 @@ def get_option_parser():
return parser


def load_huey(path):
try:
return load_class(path)
except:
cur_dir = os.getcwd()
if cur_dir not in sys.path:
sys.path.insert(0, cur_dir)
return load_huey(path)
err('Error importing %s' % path)
raise


if __name__ == '__main__':
parser = get_option_parser()
options, args = parser.parse_args()
Expand All @@ -89,11 +102,7 @@ def get_option_parser():
err('Example: huey_consumer.py app.queue.huey_instance')
sys.exit(1)

try:
huey_instance = load_class(args[0])
except:
err('Error importing %s' % args[0])
raise
huey_instance = load_huey(args[0])

consumer = Consumer(
huey_instance,
Expand Down

0 comments on commit 9cd4724

Please sign in to comment.