|  | @@ -3,7 +3,11 @@ import os
 | 
	
		
			
				|  |  |  import sys
 | 
	
		
			
				|  |  |  import warnings
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  | -from multiprocessing import get_logger, current_process
 | 
	
		
			
				|  |  | +try:
 | 
	
		
			
				|  |  | +    from multiprocessing import current_process
 | 
	
		
			
				|  |  | +except ImportError:
 | 
	
		
			
				|  |  | +    current_process = None
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |  from nose import SkipTest
 | 
	
		
			
				|  |  |  from kombu.tests.utils import redirect_stdouts
 | 
	
	
		
			
				|  | @@ -11,7 +15,7 @@ from kombu.tests.utils import redirect_stdouts
 | 
	
		
			
				|  |  |  from celery import Celery
 | 
	
		
			
				|  |  |  from celery import platforms
 | 
	
		
			
				|  |  |  from celery import signals
 | 
	
		
			
				|  |  | -from celery.app import app_or_default
 | 
	
		
			
				|  |  | +from celery import current_app
 | 
	
		
			
				|  |  |  from celery.apps import worker as cd
 | 
	
		
			
				|  |  |  from celery.bin.celeryd import WorkerCommand, windows_main, \
 | 
	
		
			
				|  |  |                                 main as celeryd_main
 | 
	
	
		
			
				|  | @@ -45,7 +49,7 @@ def disable_stdouts(fun):
 | 
	
		
			
				|  |  |  class _WorkController(object):
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |      def __init__(self, *args, **kwargs):
 | 
	
		
			
				|  |  | -        self.logger = app_or_default().log.get_default_logger()
 | 
	
		
			
				|  |  | +        self.logger = current_app.log.get_default_logger()
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |      def start(self):
 | 
	
		
			
				|  |  |          pass
 | 
	
	
		
			
				|  | @@ -120,7 +124,7 @@ class test_Worker(unittest.TestCase):
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |      @disable_stdouts
 | 
	
		
			
				|  |  |      def test_init_queues(self):
 | 
	
		
			
				|  |  | -        app = app_or_default()
 | 
	
		
			
				|  |  | +        app = current_app
 | 
	
		
			
				|  |  |          c = app.conf
 | 
	
		
			
				|  |  |          p, app.amqp.queues = app.amqp.queues, {
 | 
	
		
			
				|  |  |                  "celery": {"exchange": "celery",
 | 
	
	
		
			
				|  | @@ -171,7 +175,7 @@ class test_Worker(unittest.TestCase):
 | 
	
		
			
				|  |  |          self.assertEqual(worker1.loglevel, 0xFFFF)
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |      def test_warns_if_running_as_privileged_user(self):
 | 
	
		
			
				|  |  | -        app = app_or_default()
 | 
	
		
			
				|  |  | +        app = current_app
 | 
	
		
			
				|  |  |          if app.IS_WINDOWS:
 | 
	
		
			
				|  |  |              raise SkipTest("Not applicable on Windows")
 | 
	
		
			
				|  |  |          warnings.resetwarnings()
 | 
	
	
		
			
				|  | @@ -316,6 +320,10 @@ class test_funs(unittest.TestCase):
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |      @disable_stdouts
 | 
	
		
			
				|  |  |      def test_set_process_status(self):
 | 
	
		
			
				|  |  | +        try:
 | 
	
		
			
				|  |  | +            import setproctitle
 | 
	
		
			
				|  |  | +        except ImportError:
 | 
	
		
			
				|  |  | +            raise SkipTest("setproctitle not installed")
 | 
	
		
			
				|  |  |          worker = Worker(hostname="xyzza")
 | 
	
		
			
				|  |  |          prev1, sys.argv = sys.argv, ["Arg0"]
 | 
	
		
			
				|  |  |          try:
 | 
	
	
		
			
				|  | @@ -338,7 +346,7 @@ class test_funs(unittest.TestCase):
 | 
	
		
			
				|  |  |      @disable_stdouts
 | 
	
		
			
				|  |  |      def test_parse_options(self):
 | 
	
		
			
				|  |  |          cmd = WorkerCommand()
 | 
	
		
			
				|  |  | -        cmd.app = app_or_default()
 | 
	
		
			
				|  |  | +        cmd.app = current_app
 | 
	
		
			
				|  |  |          opts, args = cmd.parse_options("celeryd", ["--concurrency=512"])
 | 
	
		
			
				|  |  |          self.assertEqual(opts.concurrency, 512)
 | 
	
		
			
				|  |  |  
 | 
	
	
		
			
				|  | @@ -358,7 +366,7 @@ class test_signal_handlers(unittest.TestCase):
 | 
	
		
			
				|  |  |      class _Worker(object):
 | 
	
		
			
				|  |  |          stopped = False
 | 
	
		
			
				|  |  |          terminated = False
 | 
	
		
			
				|  |  | -        logger = get_logger()
 | 
	
		
			
				|  |  | +        logger = current_app.log.get_default_logger()
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |          def stop(self, in_sighandler=False):
 | 
	
		
			
				|  |  |              self.stopped = True
 | 
	
	
		
			
				|  | @@ -404,6 +412,8 @@ class test_signal_handlers(unittest.TestCase):
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |      @disable_stdouts
 | 
	
		
			
				|  |  |      def test_worker_int_handler_only_stop_MainProcess(self):
 | 
	
		
			
				|  |  | +        if current_process is None:
 | 
	
		
			
				|  |  | +            raise SkipTest("only relevant for multiprocessing")
 | 
	
		
			
				|  |  |          process = current_process()
 | 
	
		
			
				|  |  |          name, process.name = process.name, "OtherProcess"
 | 
	
		
			
				|  |  |          try:
 | 
	
	
		
			
				|  | @@ -423,6 +433,8 @@ class test_signal_handlers(unittest.TestCase):
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |      @disable_stdouts
 | 
	
		
			
				|  |  |      def test_worker_int_again_handler_only_stop_MainProcess(self):
 | 
	
		
			
				|  |  | +        if current_process is None:
 | 
	
		
			
				|  |  | +            raise SkipTest("only relevant for multiprocessing")
 | 
	
		
			
				|  |  |          process = current_process()
 | 
	
		
			
				|  |  |          name, process.name = process.name, "OtherProcess"
 | 
	
		
			
				|  |  |          try:
 | 
	
	
		
			
				|  | @@ -443,6 +455,8 @@ class test_signal_handlers(unittest.TestCase):
 | 
	
		
			
				|  |  |          self.assertTrue(worker.stopped)
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |      def test_worker_cry_handler(self):
 | 
	
		
			
				|  |  | +        if sys.platform.startswith("java"):
 | 
	
		
			
				|  |  | +            raise SkipTest("Cry handler does not work on Jython")
 | 
	
		
			
				|  |  |          if sys.version_info > (2, 5):
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |              class Logger(object):
 | 
	
	
		
			
				|  | @@ -459,6 +473,8 @@ class test_signal_handlers(unittest.TestCase):
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |      @disable_stdouts
 | 
	
		
			
				|  |  |      def test_worker_term_handler_only_stop_MainProcess(self):
 | 
	
		
			
				|  |  | +        if current_process is None:
 | 
	
		
			
				|  |  | +            raise SkipTest("only relevant for multiprocessing")
 | 
	
		
			
				|  |  |          process = current_process()
 | 
	
		
			
				|  |  |          name, process.name = process.name, "OtherProcess"
 | 
	
		
			
				|  |  |          try:
 | 
	
	
		
			
				|  | @@ -472,6 +488,8 @@ class test_signal_handlers(unittest.TestCase):
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |      @disable_stdouts
 | 
	
		
			
				|  |  |      def test_worker_restart_handler(self):
 | 
	
		
			
				|  |  | +        if getattr(os, "execv", None) is None:
 | 
	
		
			
				|  |  | +            raise SkipTest("platform does not have excv")
 | 
	
		
			
				|  |  |          argv = []
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |          def _execv(*args):
 |