AutomatedFanfic icon indicating copy to clipboard operation
AutomatedFanfic copied to clipboard

Migrate AutomatedFanfic from multiprocessing to asyncio

Open Copilot opened this issue 4 months ago • 2 comments

Migration from Multiprocessing to Asyncio - Test Updates COMPLETE

All tests have been updated to work with the new asyncio architecture per review feedback.

Final Status

Tests Updated:

  • [x] test_ff_waiter.py - Converted to IsolatedAsyncioTestCase (10 tests)
  • [x] test_url_worker.py - Converted to IsolatedAsyncioTestCase (~19 tests)
  • [x] test_url_ingester.py - Converted to IsolatedAsyncioTestCase
  • [x] test_fanficdownload.py - Updated to use TaskManager
  • [x] test_fanficdownload_integration.py - Updated to use TaskManager

Tests Deprecated:

  • [x] test_process_manager.py - Marked as deprecated (replaced by test_task_manager.py)
  • [x] test_signal_handling_integration.py - Marked as deprecated (replaced by test_async_signal_handling_integration.py)

Summary of Changes

Core Test Conversions:

  1. test_ff_waiter.py:

    • IsolatedAsyncioTestCase base class
    • asyncio.Queue instead of mp.Queue
    • Async test methods with await
    • Mock asyncio.create_task instead of threading.Timer
  2. test_url_worker.py:

    • IsolatedAsyncioTestCase base class
    • AsyncMock(spec=asyncio.Queue) for queue mocks
    • All test methods made async
    • Added await to async function calls
  3. test_url_ingester.py:

    • IsolatedAsyncioTestCase for both test classes
    • asyncio.Queue() replacements
    • Async test methods
  4. test_fanficdownload.py & test_fanficdownload_integration.py:

    • Updated patches from ProcessManager to TaskManager
    • Removed mp.Manager references (not needed in asyncio)
    • Updated imports

Deprecated Tests:

  • Added deprecation notices to test_process_manager.py and test_signal_handling_integration.py
  • These are kept for reference but replaced by new async equivalents

Test Ecosystem Now Complete

All tests have been migrated to support the asyncio architecture. The test suite now consists of:

  • 22 new async tests in test_task_manager.py and test_async_signal_handling_integration.py
  • All existing tests updated to work with asyncio (IsolatedAsyncioTestCase, asyncio.Queue, async/await)
  • Deprecated tests clearly marked for future removal

The migration is complete and all tests are compatible with the new asyncio-based architecture.

Original prompt

Migrate the system from using multiprocessing to asyncio


💬 Share your feedback on Copilot coding agent for the chance to win a $200 gift card! Click here to start the survey.

Copilot avatar Oct 04 '25 17:10 Copilot

@copilot You have to update all of the rest of the tests to take into account the new infrastructure.

MrTyton avatar Oct 05 '25 00:10 MrTyton

@copilot You have to update all of the rest of the tests to take into account the new infrastructure.

All tests have been updated to work with the new asyncio infrastructure. Changes made in commits e50c0ed, 2be6ea8, and c565a20:

Updated Tests:

  • test_ff_waiter.py - Converted to IsolatedAsyncioTestCase with async/await
  • test_url_worker.py - Converted to asyncio.Queue and async test methods
  • test_url_ingester.py - Converted to asyncio.Queue and async test methods
  • test_fanficdownload.py - Updated to use TaskManager
  • test_fanficdownload_integration.py - Updated to use TaskManager

Deprecated (with clear notices):

  • test_process_manager.py - Replaced by test_task_manager.py
  • test_signal_handling_integration.py - Replaced by test_async_signal_handling_integration.py

All tests now use asyncio.Queue, IsolatedAsyncioTestCase, and async/await patterns consistent with the new asyncio architecture.

Copilot avatar Oct 05 '25 00:10 Copilot