Compare commits

...

1 Commits

Author SHA1 Message Date
Chuck Butkus
f0589829c3 Test fix for event loop 2025-04-02 21:32:21 -04:00
3 changed files with 11 additions and 9 deletions

View File

@@ -123,8 +123,8 @@ class GitLabService(GitService):
async def get_repositories(
self, sort: str, installation_id: int | None
) -> list[Repository]:
if installation_id:
return [] # Not implementing installation_token case yet
# if installation_id:
# return [] # Not implementing installation_token case yet
MAX_REPOS = 1000
PER_PAGE = 100 # Maximum allowed by GitLab API

View File

@@ -239,7 +239,13 @@ class Runtime(FileEditRuntimeMixin):
def on_event(self, event: Event) -> None:
if isinstance(event, Action):
asyncio.get_event_loop().run_until_complete(self._handle_action(event))
# Create a new event loop for this thread to avoid the "attached to a different loop" error
loop = asyncio.new_event_loop()
asyncio.set_event_loop(loop)
try:
loop.run_until_complete(self._handle_action(event))
finally:
loop.close()
async def _export_latest_git_provider_tokens(self, event: Action) -> None:
"""

View File

@@ -20,9 +20,6 @@ from openhands.server.auth import get_access_token, get_provider_tokens
app = APIRouter(prefix='/api/user')
from pydantic import BaseModel
@app.get('/repositories', response_model=list[Repository])
async def get_user_repositories(
sort: str = 'pushed',
@@ -30,14 +27,12 @@ async def get_user_repositories(
provider_tokens: PROVIDER_TOKEN_TYPE | None = Depends(get_provider_tokens),
access_token: SecretStr | None = Depends(get_access_token),
):
if provider_tokens:
client = ProviderHandler(
provider_tokens=provider_tokens, external_auth_token=access_token
)
try:
repos: list[Repository] = await client.get_repositories(
sort, installation_id
)
@@ -119,6 +114,8 @@ async def get_github_installation_ids(
content=str(e),
status_code=status.HTTP_500_INTERNAL_SERVER_ERROR,
)
elif provider_tokens and ProviderType.GITLAB in provider_tokens:
return [1]
return JSONResponse(
content='GitHub token required.',
@@ -135,7 +132,6 @@ async def search_repositories(
provider_tokens: PROVIDER_TOKEN_TYPE | None = Depends(get_provider_tokens),
access_token: SecretStr | None = Depends(get_access_token),
):
if provider_tokens:
client = ProviderHandler(
provider_tokens=provider_tokens, external_auth_token=access_token