Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8249689
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 7, 20262026-06-07T23:37:49+00:00 2026-06-07T23:37:49+00:00

I am trying to use the combination Django custom logger and Celery task to

  • 0

I am trying to use the combination Django custom logger and Celery task to capture certain application log messages and dump them in DynamoDB asynchronously. I have created a Django Celery task that takes a log message and transfer it to DynamoDB asynchronously. I tried to call this celery task from my custom logger to transfer it to DynamoDB asynchronously.

However, Django custom logger does not allow me to import:

from celery.task import task, Task, PeriodicTask, periodic_task

My server crashes with the below error:

ValueError: Unable to configure handler 'custom_handler': Cannot resolve 'myApp.analytics.tasks.LogHandler': cannot import name cache

I know that Django Logger docs warns against circular imports if the custom logger file
includes settings.py but I have made sure thats not the case. But it is still giving me the same error as that of circular imports.

Am I doing something wrong or is there any other way to achieve asynchronous data transfer to DynamoDB using Django custom logger and DjCelery?

Thanks for any help.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-07T23:37:50+00:00Added an answer on June 7, 2026 at 11:37 pm

    I found the solution.

    The problem was “If your settings.py specifies a custom handler class and the file defining that class also imports settings.py a circular import will occur.”

    To resolve this we need to do the import in the method body instead of the file defining the class.

    Here’s my custom LogHandler:

    import logging
    #Do not import settings here, as this would lead to circular import.
    
    
    #This custom log handler parses the message and inserts the entry to the DynamoDB tables.
     class LogHandler(logging.Handler):
       def __init__(self):
        logging.Handler.__init__(self)
        self.report_logger = logging.getLogger('reporting')
        self.report_logger.setLevel(logging.INFO)
    
       def emit(self, record):
        #Submit the task to "reporting" queue to be picked up and processed by the worker lazily.
        #myApp.analytics.tasks imports celery.task
        from myApp.analytics import tasks
        tasks.push_row_to_dynamodb.apply_async(args=[record])
        return 
    

    Hope it helps someone.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm trying create a simple background periodic task using Django-Celery-RabbitMQ combination. I installed Django
I'm trying to use the TouchSwipe plugin from Skinkers Labs in combination with jQuery
I'm trying to figure out how to use NServiceBus in combination withCommon.Logging. I just
I am trying use gem tire to search in my application. I have tables
I am getting cannot import name connections exception while trying to use django-multilingual-ng 0.1.20
I have an easy question. I'm trying to use coalesce in combination with a
I'm trying to use hub in combination with git. Note: hub simplifies git usage
I am trying to use a combination of Timecop and querying the arel where_sql
I'm developing a website in PHP and I'm trying to use OpenID for log-in
I'm new to some Java technologies; I'm trying to use a combination of struts,

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.