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

  • Home
  • SEARCH
  • 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 615735
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 13, 20262026-05-13T18:15:07+00:00 2026-05-13T18:15:07+00:00

This is a difficult problem to describe so please let me know if anything

  • 0

This is a difficult problem to describe so please let me know if anything is unclear.

I am trying to solve a possible deadlock situation in my C++ app and I am having trouble visualizing an appropriate solution. The restrictions placed on me by the two libraries I am trying to connect make my problem very complex and troublesome but it can all boil down to a simple diagram. Quite simply I have a situation like so

Python    |                 Thread 1                  Thread 2
          |
Action 1 -|-> GIL LOCK -->  Random Calls
Action 2  |   GIL LOCK <----------------------------- [Action 2]
          |                 Action 1 -- signals --->  Do_Action_1
          |                 Wait Forever              Wait on Action 2

Action 2 happens to be a timer firing, the library I am using has this timer code that will call functions after a set amount of time.

Trouble occurs when a timer fires while I am destroying the timer handler (Action 1). The timer handler will wait for the timers to finish their functions and the timer functions cannot finish because they are waiting to call a python function. In order to get into python they need to take the GIL which is being held by the timer handler destruction action.

I am wondering if its possible for me from Thread 1 to interrupt its wait on the GIL and unwind its stack to put it out of harms way of this deadlock. Although I fear going down to far into specific OS implementations I just can not think of any better solution.

In other words, I want to cancel the Action 2 call from thread 1. Is this in ANY way possible?

I should mention that I cannot edit the operation in Thread 2 ie, I cannot edit that library that is managing that thread.
I can modify python’s GIL lock to maybe be a try lock or a timed lock or maybe even a wait on a condition but that would be really hard to pull off.

I suppose the best solution would be to modify python to wait on the gil and a named condition that my Thread 1 can signal when I want to cancel its wait on the GIL. But before going down that route I want to know if I am missing anything.

  • 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-05-13T18:15:08+00:00Added an answer on May 13, 2026 at 6:15 pm

    If you’re destroying the timer handler, I figure you’re exiting the program. Before you try to exit and begin killing the timers, can you set a flag to prevent Action 1 and have Thread 1 terminate itself? I hope I’m reading your diagram right, because it doesn’t exactly match with the text…

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

Sidebar

Ask A Question

Stats

  • Questions 370k
  • Answers 370k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer First, don't use semicolons as a delimiter in a query… May 14, 2026 at 6:39 pm
  • Editorial Team
    Editorial Team added an answer Turns out I needed to add a call to [self.tableView… May 14, 2026 at 6:39 pm
  • Editorial Team
    Editorial Team added an answer If none of your checkboxes was selected $services would be… May 14, 2026 at 6:39 pm

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

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.