public inbox for gdb-patches@sourceware.org
 help / color / mirror / Atom feed
* [PATCH] Refactor DAP queue handling
@ 2023-11-15 17:21 Tom Tromey
  2023-11-21 11:14 ` Alexandra Petlanova Hajkova
  0 siblings, 1 reply; 3+ messages in thread
From: Tom Tromey @ 2023-11-15 17:21 UTC (permalink / raw)
  To: gdb-patches; +Cc: Tom Tromey

A couple of spots in the DAP code use the same workaround for the
absence of queue.SimpleQueue before Python 3.6.  This patch
consolidates these into a single spot.
---
 gdb/python/lib/gdb/dap/server.py  |  8 ++------
 gdb/python/lib/gdb/dap/startup.py | 13 +++++++++----
 2 files changed, 11 insertions(+), 10 deletions(-)

diff --git a/gdb/python/lib/gdb/dap/server.py b/gdb/python/lib/gdb/dap/server.py
index 62bf240c1e9..529ed902e17 100644
--- a/gdb/python/lib/gdb/dap/server.py
+++ b/gdb/python/lib/gdb/dap/server.py
@@ -15,11 +15,10 @@
 
 import inspect
 import json
-import queue
-import sys
 
 from .io import start_json_writer, read_json
 from .startup import (
+    DAPQueue,
     in_dap_thread,
     start_thread,
     log,
@@ -50,10 +49,7 @@ class Server:
         # This queue accepts JSON objects that are then sent to the
         # DAP client.  Writing is done in a separate thread to avoid
         # blocking the read loop.
-        if sys.version_info[0] == 3 and sys.version_info[1] <= 6:
-            self.write_queue = queue.Queue()
-        else:
-            self.write_queue = queue.SimpleQueue()
+        self.write_queue = DAPQueue()
         self.done = False
         global _server
         _server = self
diff --git a/gdb/python/lib/gdb/dap/startup.py b/gdb/python/lib/gdb/dap/startup.py
index eba072147ee..a16b51f7cf5 100644
--- a/gdb/python/lib/gdb/dap/startup.py
+++ b/gdb/python/lib/gdb/dap/startup.py
@@ -23,6 +23,14 @@ import traceback
 import sys
 
 
+# Adapt to different Queue types.  This is exported for use in other
+# modules as well.
+if sys.version_info[0] == 3 and sys.version_info[1] <= 6:
+    DAPQueue = queue.Queue
+else:
+    DAPQueue = queue.SimpleQueue
+
+
 # The GDB thread, aka the main thread.
 _gdb_thread = threading.current_thread()
 
@@ -158,10 +166,7 @@ def send_gdb_with_response(fn):
     """
     if isinstance(fn, str):
         fn = Invoker(fn)
-    if sys.version_info[0] == 3 and sys.version_info[1] <= 6:
-        result_q = queue.Queue()
-    else:
-        result_q = queue.SimpleQueue()
+    result_q = DAPQueue()
 
     def message():
         try:
-- 
2.41.0


^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] Refactor DAP queue handling
  2023-11-15 17:21 [PATCH] Refactor DAP queue handling Tom Tromey
@ 2023-11-21 11:14 ` Alexandra Petlanova Hajkova
  2023-11-21 14:53   ` Tom Tromey
  0 siblings, 1 reply; 3+ messages in thread
From: Alexandra Petlanova Hajkova @ 2023-11-21 11:14 UTC (permalink / raw)
  To: Tom Tromey; +Cc: gdb-patches

[-- Attachment #1: Type: text/plain, Size: 398 bytes --]

On Wed, Nov 15, 2023 at 6:21 PM Tom Tromey <tromey@adacore.com> wrote:

> A couple of spots in the DAP code use the same workaround for the
> absence of queue.SimpleQueue before Python 3.6.  This patch
> consolidates these into a single spot.
> ---
>
> I can confirm this change does not cause any regressions for Fedora
Rawhide ppc64le. But it does not apply cleanly, and needs rebase.

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] Refactor DAP queue handling
  2023-11-21 11:14 ` Alexandra Petlanova Hajkova
@ 2023-11-21 14:53   ` Tom Tromey
  0 siblings, 0 replies; 3+ messages in thread
From: Tom Tromey @ 2023-11-21 14:53 UTC (permalink / raw)
  To: Alexandra Petlanova Hajkova; +Cc: Tom Tromey, gdb-patches

>>>>> "Alexandra" == Alexandra Petlanova Hajkova <ahajkova@redhat.com> writes:

Alexandra> On Wed, Nov 15, 2023 at 6:21 PM Tom Tromey <tromey@adacore.com> wrote:
Alexandra>  A couple of spots in the DAP code use the same workaround for the
Alexandra>  absence of queue.SimpleQueue before Python 3.6.  This patch
Alexandra>  consolidates these into a single spot.
Alexandra>  ---

Alexandra> I can confirm this change does not cause any regressions for
Alexandra> Fedora Rawhide ppc64le. But it does not apply cleanly, and
Alexandra> needs rebase.

I rebased it.  I'm going to check it in now.
Since this one is just a small cleanup, I'm not going to apply it to
gdb-14.

Feel free to send reviewed-by (or whatever) headers if you like, btw.

thanks,
Tom

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2023-11-21 14:53 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-11-15 17:21 [PATCH] Refactor DAP queue handling Tom Tromey
2023-11-21 11:14 ` Alexandra Petlanova Hajkova
2023-11-21 14:53   ` Tom Tromey

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).