Skip to content

Commit

Permalink
debug the main.py function for the new game function
Browse files Browse the repository at this point in the history
  • Loading branch information
Francois-lenne committed Mar 25, 2024
1 parent a7f0c59 commit 0e8f1a8
Show file tree
Hide file tree
Showing 4 changed files with 52 additions and 1 deletion.
17 changes: 17 additions & 0 deletions .gcloudignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
# This file specifies files that are *not* uploaded to Google Cloud
# using gcloud. It follows the same syntax as .gitignore, with the addition of
# "#!include" directives (which insert the entries of the given .gitignore-style
# file at that point).
#
# For more information, run:
# $ gcloud topic gcloudignore
#
.gcloudignore
# If you would like to upload your .git directory, .gitignore file or files
# from your .gitignore file, remove the corresponding line
# below:
.git
.gitignore

node_modules
#!include:.gitignore
8 changes: 7 additions & 1 deletion main.py
Original file line number Diff line number Diff line change
Expand Up @@ -175,8 +175,14 @@ def new_game(df_game, old_game_df):

df_game_new = df_game[~df_game['id'].isin(old_game_df['id'])]


table_id = f"{project_id}.{dataset_name}.{table_name_game}"

table = client.get_table(table_id)
schema = [field.name for field in table.schema]

if len(df_game_new) > 0:
client.insert_rows_from_dataframe(f"{project_id}.{dataset_name}.{table_name_game}", df_game_new)
client.insert_rows_from_dataframe(table, df_game_new)

return f"Loaded {len(df_game_new)} rows to {table_name_game}"

Expand Down
27 changes: 27 additions & 0 deletions test.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
from time import sleep
import asyncio


def background(f):
def wrapper(*args,**kwargs):
return asyncio.get_event_loop().run_in_executor(None,f,*args,**kwargs)
return wrapper

@background
def loop_function(i):
for j in range(10):
loop_function2(j)

def loop_function2(i):
for k in range(10):
sleep(2)
loop_function3(k)


def loop_function3(i):
print(i)
sleep(2)

loop = asyncio.get_event_loop()
looper = asyncio.gather(*[loop_function(i) for i in range(100) ])
loop.run_until_complete(looper)
1 change: 1 addition & 0 deletions text.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
gGnj0vj7GTpCMDHdUU7AoVhAIBWaNcS74VGyODkEt4ZDV9SdQiI4LRBGwgnryT2r

0 comments on commit 0e8f1a8

Please sign in to comment.