• 14 Posts
  • 19 Comments
Joined 1 year ago
cake
Cake day: July 13th, 2023

help-circle





  • import asyncio
    from asyncio import Queue
    
    async def read_input(queue: Queue):
        while True:
            user_input = await loop.run_in_executor(None, input, "Enter something: ")
            await queue.put(user_input)
    
    async def process_input(queue: Queue):
        while True:
            user_input = await queue.get()
            if user_input == "quit":
                break
            print(f"Processing input: {user_input}")
            await asyncio.sleep(1) # Simulate processing time
    
    async def main():
        queue = Queue()
        task1 = asyncio.create_task(read_input(queue))
        task2 = asyncio.create_task(process_input(queue))
    
        await asyncio.gather(task1, task2)
    
    if __name__ == "__main__":
        loop = asyncio.get_event_loop()
    
        try:
            loop.run_until_complete(main())
        except KeyboardInterrupt:
            pass
        finally:
            loop.close()
    

    The read_input function acts as a producer, continuously reading input from the command line and putting it into a Queue.

    The process_input function acts as a consumer, taking items from the Queue and processing them. It prints out each input and simulates processing time with asyncio.sleep().

    The main function creates both tasks, runs them concurrently with asyncio.gather(), and handles cleanup of the event loop.

    This allows the producer and consumer to run asynchronously, communicating through the queue. The input call runs in a threadpool executor to avoid blocking the async loop.

















  • Look for AppStream metadata files like .desktop and .metainfo.xml. Presence of these suggests the package provides a graphical application.

    I want to check all the packages in the Arch/AUR repositories, not just installed packages.

    To get a list of all installed Arch/AUR packages that aren’t libraries or dependencies, i.e., they aren’t required by any other packages, you can use the pacman command with the -Qent flag. This will list all explicitly installed native packages that are not direct or optional dependencies:

    pacman -Qent
    

    However, this command will only list packages from the official repositories and not the AUR packages. To get a list of all installed AUR packages, you can use the pacman -Qmq command:

    pacman -Qmq
    

    To filter out AUR packages that are not required by any other packages, you can combine the output of the above commands with some additional scripting. Here’s an example of how you can achieve this:

    comm -23 <(pacman -Qmq | sort) <(pacman -Qqg base | sort -u)
    

    This command will list all installed AUR packages that are not required by any other packages. Note that this command assumes that you have the comm utility installed on your system. If you don’t have it, you can install it by installing the coreutils package:

    sudo pacman -S coreutils
    

    Keep in mind that this approach might not be perfect, as it may still include some packages that are indirectly required by other packages. However, it should give you a good starting point for identifying packages that are not libraries or dependencies.